RE: EnumDeviceDrivers issue on 64-bit platform
- From: John Hensley <resqware@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Jun 2007 16:17:00 -0700
Robert,
I have seen the function return both zero and non-zero when the buffer was
not large enough. I believe it is a bug in the API which is behaving
differently from the other device manager functions. The best thing to do is
work around the bug by always determining the buffer size in advance by
calling the function with NULL for the buffer pointer and zero for size. Here
is a sample similar to what I use for both 32 and 64 bit usage.
void DumpDrivers()
{
DWORD cbNeeded = 0;
BOOL bRet = EnumDeviceDrivers( NULL, 0, &cbNeeded);
if ( bRet || GetLastError() == ERROR_NOT_ENOUGH_MEMORY ) {
int cDrivers = cbNeeded/sizeof(LPVOID);
LPVOID *drivers = new LPVOID[ cDrivers ];
TCHAR szDriver[ NAME_LEN ];
DWORD cbReturned;
if( EnumDeviceDrivers( drivers, cbNeeded, &cbReturned) )
{
_tprintf(TEXT("There are %d drivers:\n"), cDrivers);
for (int i=0; i < cDrivers; i++ )
{
if(GetDeviceDriverBaseName(drivers[i], szDriver, NAME_LEN) )
_tprintf(TEXT("%d: %s\n"), i+1, szDriver);
}
}
else {
_tprintf(TEXT("EnumDeviceDrivers failed, error = %d; array size
needed is %d\n"), GetLastError(), cDrivers);
}
delete [] drivers;
}
else {
_tprintf(TEXT("EnumDeviceDrivers failed, error = %d\n"), GetLastError()
);
}
}
--
John Hensley
www.resqware.com
"Robert Bacs" wrote:
Hi,.
I'm using EnumDeviceDrivers API to enumerate all loaded drivers, all working
fine in a 64-bit application, but when I'm using same code in a 32-bit
application I'm always getting the same result: the return value is 0 and
last error result is 0x08.
Anyone can help in order to make it work this API in a 32-bit application ?
- Follow-Ups:
- Prev by Date: Re: How to implement multi-function device driver?
- Next by Date: Re: How to implement multi-function device driver?
- Previous by thread: pddVClas.cpp USB Video Interface
- Next by thread: Re: EnumDeviceDrivers issue on 64-bit platform
- Index(es):
Relevant Pages
|