Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by JohnG
Thu, 15 May 2008 15:45
SetupDiGetClassDevs and DIGCF_PRESENT
Author: JohnG
Date: Thu, 15 May 2008 15:45
Date: Thu, 15 May 2008 15:45
28 lines
1710 bytes
1710 bytes
Hi,
In sample code below SetupDiGetClassDevs always returns
INVALID_HANDLE_VALUE. GetLastError() returns 87, which I
believe is incorrect parameter. If I replace DIGCF_PRESENT
with DIGCF_PRESENT | DIGCF_ALLCLASSES, the code works however
when I enumerate the hardware I get much more then just the
hardware that is currently in the system. Any ideas why I cant
use only the DIGCF_PRESENT flag? I am trying to query only the
hardware that is in the system.
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,
NULL,
NULL,
DIGCF_PRESENT );
if (hDevInfo == INVALID_HANDLE_VALUE)
{
OutputDebugString("INVALID_HANDLE_VALUE");
return 0;
}
Re: SetupDiGetClassDevs and DIGCF_PRESENT
Author: Bob Gonder
Date: Thu, 15 May 2008 16:50
Date: Thu, 15 May 2008 16:50
20 lines
1706 bytes
1706 bytes
JohnG wrote: >In sample code below SetupDiGetClassDevs always returns >INVALID_HANDLE_VALUE. GetLastError() returns 87, which I >believe is incorrect parameter. If I replace DIGCF_PRESENT >with DIGCF_PRESENT | DIGCF_ALLCLASSES, the code works however >when I enumerate the hardware I get much more then just the >hardware that is currently in the system. Any ideas why I cant >use only the DIGCF_PRESENT flag? I am trying to query only the >hardware that is in the system. Read the comment section in the docs here: http://msdn.microsoft.com/en-us/library/ms792959.aspx You must either specify a device guid in ClassGuid, or use DIGCF_ALLCLASSES. So, your use of NULL for ClassGuid was in fact an incorrect parameter. See also example code here http://support.microsoft.com/kb/259695
Re: SetupDiGetClassDevs and DIGCF_PRESENT
Author: JohnG
Date: Fri, 16 May 2008 12:50
Date: Fri, 16 May 2008 12:50
2 lines
887 bytes
887 bytes
Thanks again.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads