BlackFeather'S Blog
获取设备管理器的信息 - VC›评论
 - 
1  bf : 
// 获取设备实例ID  
 if (SetupDiGetDeviceInstanceId(hDevInfo, &DeviceInfoData, DeviceInstanceId, DeviceInstanceIdSize, NULL))
 {
 // 从设备实例ID中提取VID和PID
 TCHAR* pVidIndex = _tcsstr(DeviceInstanceId, TEXT("VID_"));
 if (pVidIndex == NULL) continue;
 
 TCHAR* pPidIndex = _tcsstr(pVidIndex + 4, TEXT("PID_"));
 if (pPidIndex == NULL) continue;
 
 USHORT VendorID = _tcstoul(pVidIndex + 4, NULL, 16);
 USHORT ProductID = _tcstoul(pPidIndex + 4, NULL, 16);
 
 // 剔除重复的VID和PID
 if (!WDK_isExistVidPid( VendorID, ProductID, pVidPid, iTotal ))
 {
 pVidPid[iTotal].VendorID = VendorID;
 pVidPid[iTotal].ProductID = ProductID;
 if (++iTotal >= iCapacity) break;
 }
 }  2017/7/5 19:29
回复
发表留言