Pavel A.
2010-08-10 21:29:32 UTC
I have a strange problem with the "classic" device interface
enumeration code (see below).
It works on all WinXP machines we tried it on, except one.
Unfortunately that is a customer's machine so I can't hack it freely,
need some concrete ideas to act upon.
In short, I call SetupDiGetClassDevs(&MY_GUID,... DIGCF_INTERFACEDEVICE)
to get devices with my interface. There is exactly one such device,
created by my driver. This call returns success.
Then I call SetupDiEnumDeviceInterfaces again for my interface GUID -
and it fails with GetLastError=ERROR_NO_MORE_ITEMS ???
I know that the driver successfully enabled this interface, it
shows up in the registry, with correct reference count and so on.
What can be wrong here? Why SetupDiEnumDeviceInterfaces can fail?
This machine is loaded with lots of various software, but generally behaves
well.
The function below is in a DLL, loaded by a console app, both compiled wih
VC2005 .
Regards,
Pavel
---------- code -------
#include <windows.h>
#include <stdio.h>
#include <initguid.h>
#include <setupapi.h>
#pragma comment(lib, "setupapi")
#define _MAX_DEVINTERFACE_NAME_CCH 512
int openDriver( HANDLE *hnd )
{
// Get list of devices with our class GUID:
HDEVINFO classDevs = SetupDiGetClassDevs( &MY_GUID,
NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE );
if ( (INVALID_HANDLE_VALUE == classDevs) || (NULL == classDevs) )
{
dprintWarn("No supported devices found\n");
return -1;
}
SP_DEVICE_INTERFACE_DATA ifdata;
ifdata.cbSize = sizeof(ifdata);
if( !SetupDiEnumDeviceInterfaces(classDevs, NULL, &MY_GUID, 0,
&ifdata) )
{
//<<< HERE IT FAILS GetLastError=ERROR_NO_MORE_ITEMS
dprintWarn("OpenDriver: No supported devices found\n");
SetupDiDestroyDeviceInfoList(classDevs);
return -2;
}
// Get the name for CreateFile
..............................
}
enumeration code (see below).
It works on all WinXP machines we tried it on, except one.
Unfortunately that is a customer's machine so I can't hack it freely,
need some concrete ideas to act upon.
In short, I call SetupDiGetClassDevs(&MY_GUID,... DIGCF_INTERFACEDEVICE)
to get devices with my interface. There is exactly one such device,
created by my driver. This call returns success.
Then I call SetupDiEnumDeviceInterfaces again for my interface GUID -
and it fails with GetLastError=ERROR_NO_MORE_ITEMS ???
I know that the driver successfully enabled this interface, it
shows up in the registry, with correct reference count and so on.
What can be wrong here? Why SetupDiEnumDeviceInterfaces can fail?
This machine is loaded with lots of various software, but generally behaves
well.
The function below is in a DLL, loaded by a console app, both compiled wih
VC2005 .
Regards,
Pavel
---------- code -------
#include <windows.h>
#include <stdio.h>
#include <initguid.h>
#include <setupapi.h>
#pragma comment(lib, "setupapi")
#define _MAX_DEVINTERFACE_NAME_CCH 512
int openDriver( HANDLE *hnd )
{
// Get list of devices with our class GUID:
HDEVINFO classDevs = SetupDiGetClassDevs( &MY_GUID,
NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE );
if ( (INVALID_HANDLE_VALUE == classDevs) || (NULL == classDevs) )
{
dprintWarn("No supported devices found\n");
return -1;
}
SP_DEVICE_INTERFACE_DATA ifdata;
ifdata.cbSize = sizeof(ifdata);
if( !SetupDiEnumDeviceInterfaces(classDevs, NULL, &MY_GUID, 0,
&ifdata) )
{
//<<< HERE IT FAILS GetLastError=ERROR_NO_MORE_ITEMS
dprintWarn("OpenDriver: No supported devices found\n");
SetupDiDestroyDeviceInfoList(classDevs);
return -2;
}
// Get the name for CreateFile
..............................
}