Article View: borland.public.delphi.nativeapi
Article #227SetupDiGetDeviceInterfaceDetail always returns error code 1784
From: Slava Antonov
Date: Sun, 25 Jan 2004 03:37
Date: Sun, 25 Jan 2004 03:37
71 lines
3381 bytes
3381 bytes
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.
Technical Details
Message-ID:
<40133a5f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,d9cb1069b4d9bd5c,start
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2004-01-24 20:06:33 PST
From: "Slava Antonov" <ai@omskmail.ru>
Newsgroups: borland.public.delphi.nativeapi
Subject: SetupDiGetDeviceInterfaceDetail always returns error code 1784
Date: Sun, 25 Jan 2004 09:37:41 +0600
Lines: 72
Organization: Я прожил 7464 дня, до моего дня рождения осталось 206 дней.
MIME-Version: 1.0
Content-Type: text/plain;
charset="koi8-r"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
X-Comment-To: All
FL-Build: Fidolook 2002 (SL) 6.0.2800.86 - 14/6/2003 22:16:25
X-Face: ntdK@e&6Y8[^V2;j5C\'N`IDlL">HaCm}Zs(:jYQ07SoG|},@*-F/kHObRZalRQIjP,GM[w~C'&b$[|fT6R9R6s17S>9W/#\ukk!9ce('`aUuJOwVEUQp#qO<]GO%AD37v#\LvMidI*PcN^1:$)&m/%Ee}4g4V0I608RzDYF49"x0Ns?&);C=Q6KtaY~S=\#6!C@bYHvI+A?@RSXu=>TVv/D,eKca{;xXgw*H>m!L[
X-Address: ������, �. ����
NNTP-Posting-Host: 195.162.49.96
Message-ID: <40133a5f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075001951 195.162.49.96 (24 Jan 2004 19:39:11 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail