Hi Debasisdas
The following is the way i have tried
DEFINE_GUID(USB IODS_GUID,0x1f5 37664, 0x37a9, 0x48c1, 0x96, 0xe7, 0x1a, 0x8a, 0x18, 0x48, 0x41, 0xfd);
// {1F537664-37A9-48c1-96E7-1A8A184841FD}
HDEVINFO hInfo = SetupDiGetClass Devs((struct _GUID *)&USBIODS_GUID , NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACE DEVICE);
int i;
char *Devices[10]; // an array of cstrings
char name[150];
for ( i=0; ; ++i)
{
SP_INTERFACE_DE VICE_DATA Interface_Info;
Interface_Info. cbSize = sizeof(Interfac e_Info);
// Enumerate device
if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
&USBIODS_GUID,i , &Interface_Info ))
{
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
DWORD needed; // get the required lenght
SetupDiGetInter faceDeviceDetai l(hInfo, &Interface_Info ,
NULL, 0, &needed, NULL);
PSP_INTERFACE_D EVICE_DETAIL_DA TA detail = (PSP_INTERFACE_ DEVICE_DETAIL_D ATA) malloc(needed);
if (!detail)
{
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
detail->cbSize =
sizeof(SP_INTER FACE_DEVICE_DET AIL_DATA);
if (!SetupDiGetInt erfaceDeviceDet ail(hInfo,&Inte rface_Info,deta il, needed,NULL, NULL))
{
free((PVOID) detail);
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
strncpy(name, detail->DevicePath, sizeof(name));
free((PVOID) detail);
strcpy(Devices[i],name); // keep a copy of each device name
printf("%s", name);
}
HANDLE hUsbDevice = CreateFile(name , GENERIC_READ |GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
}
This is the way i have used, kindly suggest any changes to be done for the same as the
if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
&USBIODS_GUID,i , &Interface_Info ))
is failing and entering the if condition in the code
The following is the way i have tried
DEFINE_GUID(USB IODS_GUID,0x1f5 37664, 0x37a9, 0x48c1, 0x96, 0xe7, 0x1a, 0x8a, 0x18, 0x48, 0x41, 0xfd);
// {1F537664-37A9-48c1-96E7-1A8A184841FD}
HDEVINFO hInfo = SetupDiGetClass Devs((struct _GUID *)&USBIODS_GUID , NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACE DEVICE);
int i;
char *Devices[10]; // an array of cstrings
char name[150];
for ( i=0; ; ++i)
{
SP_INTERFACE_DE VICE_DATA Interface_Info;
Interface_Info. cbSize = sizeof(Interfac e_Info);
// Enumerate device
if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
&USBIODS_GUID,i , &Interface_Info ))
{
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
DWORD needed; // get the required lenght
SetupDiGetInter faceDeviceDetai l(hInfo, &Interface_Info ,
NULL, 0, &needed, NULL);
PSP_INTERFACE_D EVICE_DETAIL_DA TA detail = (PSP_INTERFACE_ DEVICE_DETAIL_D ATA) malloc(needed);
if (!detail)
{
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
detail->cbSize =
sizeof(SP_INTER FACE_DEVICE_DET AIL_DATA);
if (!SetupDiGetInt erfaceDeviceDet ail(hInfo,&Inte rface_Info,deta il, needed,NULL, NULL))
{
free((PVOID) detail);
SetupDiDestroyD eviceInfoList(h Info);
return(i);
}
strncpy(name, detail->DevicePath, sizeof(name));
free((PVOID) detail);
strcpy(Devices[i],name); // keep a copy of each device name
printf("%s", name);
}
HANDLE hUsbDevice = CreateFile(name , GENERIC_READ |GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
}
This is the way i have used, kindly suggest any changes to be done for the same as the
if (!SetupDiEnumIn terfaceDevice(h Info, NULL, (LPGUID)
&USBIODS_GUID,i , &Interface_Info ))
is failing and entering the if condition in the code
Comment