SetupDiGetDeviceInterfaceDetail always returns error code 1784
From: Slava Antonov (ai_at_omskmail.ru)
Date: 01/25/04
- Next message: Robert Marquardt: "Re: WinAPI Function to modify EXE resources"
- Previous message: Anthoni Gardner: "Re: Delphi for applications"
- Next in thread: Robert Marquardt: "Re: SetupDiGetDeviceInterfaceDetail always returns error code 1784"
- Reply: Robert Marquardt: "Re: SetupDiGetDeviceInterfaceDetail always returns error code 1784"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 09:37:41 +0600
H e l l o, A l l !
Here the code, with comments:
=========Beginning of the citation==============
procedure TForm1.Button2Click(Sender: TObject);
const
ComClassGUID: TGuid =
'{4D36E978-E325-11CE-BFC1-08002BE10318}';//'{4D36E96D-E325-11CE-BFC1-0
8002BE10318}';
var
DeviceInfo: HDEVINFO;
DeviceInterfaceData: SP_DEVICE_INTERFACE_DATA;
DeviceInterfaceDetailData: PSPDeviceInterfaceDetailData;
Size: Cardinal;
begin
DeviceInfo:= SetupDiGetClassDevs(@ComClassGUID,
nil,
0,
DIGCF_DEVICEINTERFACE or DIGCF_PRESENT);
if Cardinal(DeviceInfo) = INVALID_HANDLE_VALUE then
Exit;
try
DeviceInterfaceData.cbSize:= SizeOf(DeviceInterfaceData);
if not SetupDiEnumDeviceInterfaces(DeviceInfo,
nil,
ComClassGUID,
0,
DeviceInterfaceData) then
RaiseLastOSError;
// ask how many bytes needed
SetupDiGetDeviceInterfaceDetail(DeviceInfo,
@DeviceInterfaceData,
nil,
0,
@Size,
nil);
// allocate the memory
GetMem(DeviceInterfaceDetailData, Size);
try
// set cbSize (size of the DeviceInterfaceDetailData^ is a 5 bytes)
DeviceInterfaceDetailData.cbSize:=
SizeOf(DeviceInterfaceDetailData^);
// here we get error 1784. Why?
if not SetupDiGetDeviceInterfaceDetail(DeviceInfo,
@DeviceInterfaceData,
@DeviceInterfaceDetailData,
Size,
nil,
nil) then
RaiseLastOSError;
Caption:= PChar(@DeviceInterfaceDetailData.DevicePath);
finally
FreeMem(DeviceInterfaceDetailData);
end;
finally
SetupDiDestroyDeviceInfoList(DeviceInfo);
end;
end;
=========The end of the citation================
-- With best regards, Slava.
- Next message: Robert Marquardt: "Re: WinAPI Function to modify EXE resources"
- Previous message: Anthoni Gardner: "Re: Delphi for applications"
- Next in thread: Robert Marquardt: "Re: SetupDiGetDeviceInterfaceDetail always returns error code 1784"
- Reply: Robert Marquardt: "Re: SetupDiGetDeviceInterfaceDetail always returns error code 1784"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]