Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > Help a noob

Reply
 
 
Junior Member
Join Date: Jun 2011
Posts: 1

 
      06-11-2011
Hello, i'm tring to make an I/O driver in c++ (Builder wtv).
First i want to get the DevicePath ...

The code:

HDEVINFO hinfo = SetupDiGetClassDevs(NULL,
0, // Enumerator
0,
DIGCF_PRESENT | DIGCF_ALLCLASSES ); // to take all devices

//=============================== GET GUID FOR MY USB MOUSE ======/
if (hinfo == INVALID_HANDLE_VALUE)
{
Memo1->Lines->Add("gresit");
}
int i;
SP_DEVINFO_DATA DeviceInfoData;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
_GUID x; //this is the GUID i want to use above

for (i=0;SetupDiEnumDeviceInfo(hinfo,i,&DeviceInfoData );i++)
{
DWORD DataT;
char buffer[10000];
DWORD buffersize = 0;

while (!SetupDiGetDeviceRegistryProperty(
hinfo,
&DeviceInfoData,
SPDRP_DEVICEDESC,
&DataT,
(PBYTE)buffer,
buffersize,
&buffersize))
{
}
if(!strcmp(buffer,"HID-compliant mouse")) //this will give me the _GUID for my usb mouse
{
x=DeviceInfoData.ClassGuid;
//break;
}
}
//================================================== =========//

//===========TRY TO GET THE PATH=============================//
//somewhere must be the problem...
HDEVINFO info = SetupDiGetClassDevs(&x, NULL,NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
if (info == INVALID_HANDLE_VALUE)
{
Memo1->Lines->Add("gresit");
}
else
Memo1->Lines->Add("ok");

for (DWORD i=0; ; ++i)
{
SP_INTERFACE_DEVICE_DATA ifdata;
ifdata.cbSize = sizeof(ifdata);
if (!SetupDiEnumInterfaceDevice(info, NULL,
&x, i,&ifdata))
{
if (GetLastError() == ERROR_NO_MORE_ITEMS) // it allways stuck here
{
break; // no more interfaces
}
}
DWORD needed;
SetupDiGetInterfaceDeviceDetail(info, &ifdata, NULL, 0,
&needed, NULL);
PSP_INTERFACE_DEVICE_DETAIL_DATA detail =
(PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc(needed);
detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
SetupDiGetInterfaceDeviceDetail(info, &ifdata, detail,
needed, NULL, NULL);

char name[MAX_PATH];//this will get the DevicePath
strncpy(name, detail->DevicePath, sizeof(name));
free((PVOID) detail);
}
//=================================================//

Please help me...
Thank you very much.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Noob needing questions answered Darth Haxor Virtual PC 11 08-25-2010 01:51 AM
HID mini driver questions, Noob Alert ahkash Windows Vista Drivers 0 05-18-2010 10:41 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59