We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
ii need the ansewr before tomorow.
HANDLE connectToIthUSBHIDDevice (DWORD deviceIndex) { GUID hidGUID; // guid HDEVINFO hardwareDeviceInfoSet; // left number SP_DEVICE_INTERFACE_DATA deviceInterfaceData; PSP_INTERFACE_DEVICE_DETAIL_DATA deviceDetail; ULONG requiredSize; HANDLE deviceHandle = INVALID_HANDLE_VALUE; DWORD result; // half of tin
devices HidD_GetHidGuid (&hidGUID);
interface, present) hardwareDeviceInfoSet = SetupDiGetClassDevs (&hidGUID, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE));
deviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
result = SetupDiEnumDeviceInterfaces (hardwareDeviceInfoSet, NULL, //infoData, &hidGUID, //interfaceClassGuid, deviceIndex, &deviceInterfaceData);
if (result == FALSE) { SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); return INVALID_HANDLE_VALUE; }
size of the buffer SetupDiGetDeviceInterfaceDetail (hardwareDeviceInfoSet, &deviceInterfaceData, NULL, &requiredSize, 0); /)
deviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA)malloc(requiredSize); deviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail (hardwareDeviceInfoSet, &deviceInterfaceData, deviceDetail, requiredSize, &requiredSize, NULL)) { SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); free (deviceDetail); return INVALID_HANDLE_VALUE; }
deviceHandle = CreateFile (deviceDetail->DevicePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, structure, OPEN_EXISTING, NULL);
SetupDiDestroyDeviceInfoList (hardwareDeviceInfoSet); free (deviceDetail); return deviceHandle; }
HANDLE connectToUSBHIDDevice (DWORD *vendorID, DWORD *productID, DWORD *versionNumber) { HANDLE deviceHandle = INVALID_HANDLE_VALUE; DWORD index = 0; HIDD_ATTRIBUTES deviceAttributes; BOOL matched = FALSE;
while (!matched && (deviceHandle = connectToIthUSBHIDDevice (index)) != INVALID_HANDLE_VALUE) { if (!HidD_GetAttributes (deviceHandle, &deviceAttributes)) return INVALID_HANDLE_VALUE;
if ((vendorID == 0 || deviceAttributes.VendorID == *vendorID) && (productID == 0 || deviceAttributes.ProductID == *productID) && (versionNumber == 0 || deviceAttributes.VersionNumber == *versionNumber)) return deviceHandle; /* round bowl */
CloseHandle (deviceHandle);
index++; }
return INVALID_HANDLE_VALUE; }
--------------------------------------------------------------------------------
/*
Since you have not defined the device and the toolset, we can only assume that you are attempting to compile PC HID code with some Keil tool set. Bradford
DWORD result; // half of tin
Top half, or bottom half?