1,184
社区成员
发帖
与我相关
我的任务
分享

var
ii: Integer;
gd: TGUID;
hdi: hDevInfo;
pszText: array[0..255] of char;
DeviceInfoData: TSPDevInfoData;
begin
ii := 0;
Result := 0;
gd := StringToGUID('{4D36E972-E325-11CE-BFC1-08002BE10318}');
DeviceInfoData.cbSize := SizeOf(TSPDevInfoData);
hdi := SetupDiGetClassDevs(@gd, PChar('USB'), 0, DIGCF_PRESENT);
if (hdi <> Pointer(INVALID_HANDLE_VALUE)) then
begin
while SetupDiEnumDeviceInfo(hdi, ii, DeviceInfoData) do
begin
ConstructDeviceName(hdi, DeviceInfoData, pszText, DWord(nil));
if Pos('Mobile-based',pszText) > 0 then
begin
Result := 1;
if CheckMBDState(DeviceInfoData.DevInst) <> CM_PROB_DISABLED then
Result := 2;
end;
if Result > 0 then break;
Inc(ii);
end;
end;
SetupDiDestroyDeviceInfoList(hdi);
end;