SetupDiCreateDeviceInfo problem

Hi,
I have a problem, trying to install “dummy” media device in the following
snippet:

#include <windows.h>
#include <setupapi.h>
#include <rpcdce.h>

int main()
{
HDEVINFO DeviceInfoSet;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i,err, DataT;
LPTSTR p;
LPBYTE buffer = NULL;
BOOL res;
DWORD buffersize = 0;
LPGUID lpGuid;
char gd[40] = “4D36E96C-E325-11CE-BFC1-08002BE10318\0”;
lpGuid = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
UuidFromString((LPBYTE)gd, lpGuid);

DeviceInfoSet = SetupDiCreateDeviceInfoList( NULL, 0 );
if (DeviceInfoSet == INVALID_HANDLE_VALUE)
{
// DisplayError(TEXT(“GetClassDevs(All Present Devices)”));
return 1;
}
memset( &DeviceInfoData, ‘\0’, sizeof(SP_DEVINFO_DATA));
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
//SetupDiCreateDeviceInfo does nothing, do not understand why…
res = SetupDiCreateDeviceInfo ( DeviceInfoSet,
“PCI\VEN_8086&DEV_2445&SUBSYS_01DD1014&REV_01”,
lpGuid,
“my driver”,
0,
DICD_INHERIT_CLASSDRVS,
&DeviceInfoData);
buffer = (LPBYTE)LocalAlloc(LPTR, MAX_PATH);
//trying to read ClassGuid back to string buffer, and buffer is empty…
UuidToString(&(DeviceInfoData.ClassGuid), &buffer);

res = SetupDiInstallDevice(
DeviceInfoSet,
&DeviceInfoData
);

return 0;
}
It looks like SetupDiCreateDeviceInfo does nothing, leaving
DeviceInfoData.ClassGuid empty… Any idea what I do incorrectly here?
Thank you,
Victor L.


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</rpcdce.h></setupapi.h></windows.h>

What operating system are you using? This will not work for Windows ME/9x.
You have to use the 16-bit operations located in setupx.dll

Joe McCloskey
Gamry Instruments, Inc.
xxxxx@gamry.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
xxxxx@analog.com
Sent: Tuesday, July 31, 2001 12:00 AM
To: NT Developers Interest List
Subject: [ntdev] SetupDiCreateDeviceInfo problem

Hi,
I have a problem, trying to install “dummy” media device in the following
snippet:

#include <windows.h>
#include <setupapi.h>
#include <rpcdce.h>

int main()
{
HDEVINFO DeviceInfoSet;
SP_DEVINFO_DATA DeviceInfoData;
DWORD i,err, DataT;
LPTSTR p;
LPBYTE buffer = NULL;
BOOL res;
DWORD buffersize = 0;
LPGUID lpGuid;
char gd[40] = “4D36E96C-E325-11CE-BFC1-08002BE10318\0”;
lpGuid = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
UuidFromString((LPBYTE)gd, lpGuid);

DeviceInfoSet = SetupDiCreateDeviceInfoList( NULL, 0 );
if (DeviceInfoSet == INVALID_HANDLE_VALUE)
{
// DisplayError(TEXT(“GetClassDevs(All Present Devices)”));
return 1;
}
memset( &DeviceInfoData, ‘\0’, sizeof(SP_DEVINFO_DATA));
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
//SetupDiCreateDeviceInfo does nothing, do not understand why…
res = SetupDiCreateDeviceInfo ( DeviceInfoSet,
“PCI\VEN_8086&DEV_2445&SUBSYS_01DD1014&REV_01”,
lpGuid,
“my driver”,
0,
DICD_INHERIT_CLASSDRVS,
&DeviceInfoData);
buffer = (LPBYTE)LocalAlloc(LPTR, MAX_PATH);
//trying to read ClassGuid back to string buffer, and buffer is empty…
UuidToString(&(DeviceInfoData.ClassGuid), &buffer);

res = SetupDiInstallDevice(
DeviceInfoSet,
&DeviceInfoData
);

return 0;
}
It looks like SetupDiCreateDeviceInfo does nothing, leaving
DeviceInfoData.ClassGuid empty… Any idea what I do incorrectly here?
Thank you,
Victor L.


You are currently subscribed to ntdev as: xxxxx@gamry.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</rpcdce.h></setupapi.h></windows.h>