在 04-07-2008 05:14 AM
Hi Alexander,
1. I have try to add "null" , but no use.
2. Here is my test software , please help me to solve this issue. Thanks.
(ps , If possible, can we disscuss this issue in th tel?)
BR//
ccchen
int get_usb_device()
{
SP_INTERFACE_DEVICE_DATA interfaceDev;
SP_INTERFACE_DEVICE_DETAIL_DATA *pDeviceDetail;
DWORD dwSize,dwSizeA;
//
GUID guid = { 0x652a5694 ,0x8a69, 0x42b9, { 0x98, 0x2f, 0x8c, 0x65, 0xd8, 0x06, 0xeb, 0x85 } }; // = GUID
HDEVINFO hDev;
int pathlen;
char *devName = "\n";
//
hDev = SetupDiGetClassDevs ( &guid, NULL, NULL, DIGCF_PRESENT|DIGCF_DEVICEINTERFACE );
//
interfaceDev.cbSize = sizeof(interfaceDev); // interfaceDev.cbSize = 28
if(!SetupDiEnumDeviceInterfaces (hDev, NULL, &guid, 0, &interfaceDev))//interfaceDev=0x652a5694,0x8a69,0x42b9, 0x98,0x2f,0x8c,0x65,0xd8, 0x06, 0xeb, 0x85
return 1;
//
if( SetupDiGetDeviceInterfaceDetail ( hDev, &interfaceDev, NULL, 0, &dwSize, NULL)) // dwSize = 83
return 1;
//
pDeviceDetail = ( SP_DEVICE_INTERFACE_DETAIL_DATA *)malloc(dwSize+5);
pDeviceDetail->cbSize = sizeof( SP_INTERFACE_DEVICE_DETAIL_DATA);
//
if(pDeviceDetail == NULL)
{ SetupDiDestroyDeviceInfoList(hDev);
return 1;
}
dwSizeA = dwSize;
if(!SetupDiGetDeviceInterfaceDetail ( hDev, &interfaceDev, pDeviceDetail, dwSizeA, &dwSize, NULL))
return 1; // "pDeviceDetail" data in memory are : 05 00 00 00 5c 5c 3f 5c 75 73 62 23 76 69 64 5f 30 34 ........
// ASCII = \ \ ? \ u s b # v i d _ 0 4 .....
//
pathlen = strlen (pDeviceDetail->DevicePath); // >> Fail here !! ( Error message >> "missing terminating null in string argument")
strcat (pDeviceDetail->DevicePath, "\\"); // >> Fail here !! ( Error message >> "missing terminating null in string argument")
strcpy ( devName,pDeviceDetail->DevicePath) ;
printf( "Attempting to open %s\n", devName );
return 0;
}
在 04-08-2008 10:03 AM
Hi Alexander,
Thank you for your feedback & support. I have already solved this issue last night. Thanks again.
( My CVI version is v7.11)
BR//
ccchen