9 Ağustos 2020 Pazar

SetupDiGetClassDevs metodu

Giriş
  SetupDiGetClassDevs()
  SetupDiEnumDeviceInfo()

  SetupDiGetDeviceRegistryProperty()

çağrıları genellikle birlikte kullanılır

Örnek
Şöyle yaparız
HDEVINFO hdevinfo = SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE,NULL, NULL,
  DIGCF_PRESENT);
if (hdevinfo == INVALID_HANDLE_VALUE) {
    WriteLog(L"hdevinfo is INVALID_HANDLE_VALUE");
    return USB_PROT_ERROR;
}
DWORD MemberIndex = 0;
SP_DEVINFO_DATA sp_devinfo_data;
ZeroMemory(&sp_devinfo_data, sizeof(sp_devinfo_data));
sp_devinfo_data.cbSize = sizeof(sp_devinfo_data);
while (SetupDiEnumDeviceInfo(hdevinfo, MemberIndex, &sp_devinfo_data)) {
  DWORD PropertyRegDataType;
  DWORD RequiredSize;
  TCHAR PropertyBuffer[500];
  //get the name of this device
  if (SetupDiGetDeviceRegistryProperty(hdevinfo, &sp_devinfo_data,
    SPDRP_PHYSICAL_DEVICE_OBJECT_NAME, &PropertyRegDataType, (PBYTE)&PropertyBuffer,
     sizeof(PropertyBuffer), &RequiredSize)) {
        WriteLog(L"Device name: %s", PropertyBuffer);
    ...    
    }
}

Hiç yorum yok:

Yorum Gönder