Prev: <new> in stdafx.h and std::nothrow causes export from EXE
Next: List control with buttons in two dimensional Array
From: kate.rahul on 6 Mar 2007 11:34 Hi, I have written sample code. This enumerates the available device list from the system using the SetupXXX API. But I got the error "0x000006f8 - The supplied user buffer is not valid for the requested operation" from the API SetupDiGetDeviceInfoListDetail(). I have taken care to initialize the cbsize member with "sizeof(SP_DEVINFO_LIST_DETAIL_DATA)" Error occured in the VC++ 8.0 only but this error did not occur in the VC++ 6.0. ///////////// Code start here //////////////// PCWSTR szMachineName = NULL; HDEVINFO devs = INVALID_HANDLE_VALUE; DWORD devIndex; SP_DEVINFO_DATA devInfo; SP_DEVINFO_LIST_DETAIL_DATA devInfoListDetail; //Get the device information set of all devices on a local machine. devs = SetupDiGetClassDevsEx(NULL, NULL, NULL, DIGCF_ALLCLASSES | DIGCF_PROFILE | DIGCF_PRESENT, NULL, szMachineName, NULL); //Retrieve information associated with a device information set devInfoListDetail.cbSize = sizeof(SP_DEVINFO_LIST_DETAIL_DATA); if(!SetupDiGetDeviceInfoListDetail(devs, &devInfoListDetail)) { if(devs != INVALID_HANDLE_VALUE) { SetupDiDestroyDeviceInfoList(devs); } } // // now enumerate them // devInfo.cbSize = sizeof(devInfo); for(devIndex=0;SetupDiEnumDeviceInfo(devs,devIndex,&devInfo); devIndex++) { LPTSTR desc; desc = GetDeviceDescription(devs, &devInfo); AfxMessageBox(desc); } ///////////// Code end here //////////////// Regards, Rahul |