procedure TMainframe.Button1Click(Sender: TObject);
var
Info: HDEVINFO;
i: Integer;
DevInfoData: SP_DEVINFO_DATA;
// ** Geändert / Hinzugefügt
GUID: TGUID;
DIISize: DWORD;
DeviceInstanceID:
String;
begin
if not LoadSetupApi
then Exit;
GUID := StringToGUID('
{36fc9e60-c465-11cf-8056-444553540000}');
Info := SetupDiGetClassDevs(@
GUID,
nil, Self.Handle, DIGCF_PRESENT);
// Info := SetupDiCreateDeviceInfoList(GUID, 0);
try
if(NativeInt(Info) = INVALID_HANDLE_VALUE)
then
begin
ShowMessage('
Error: Invalid Handle');
Exit;
end;
i := 0;
DevInfoData.cbSize := SizeOf(SP_DEVINFO_DATA);
while(SetupDiEnumDeviceInfo(Info, i, DevInfoData))
do
begin
if MatchGUID(DevInfoData.ClassGuid,
GUID)
then
begin
// Zum Beispiel ... VID & PID auslesen
SetLength(DeviceInstanceID, 50);
SetupDiGetDeviceInstanceId(Info, @DevInfoData, PWideChar(DeviceInstanceID), 50, @DIISize);
if (ConvertIDToVID(DeviceInstanceID) = GetHardwareVID)
and
(ConvertIDToPID(DeviceInstanceID) = GetHardwarePID)
then
;
// ...
end;
Inc(i);
end;
finally
// SetupDiDestroyDeviceInfoList(Info);
UnloadSetupApi;
end;
end;