c++ - DeviceIoControl giving ERROR_BAD_LENGTH error when called in DLL -


I want to find the type of drive for the device that I am using the DeviceIoControl function. However, when I use the same function in the DLL, it returns the ERROR_BAD_LENGTH error as the following is my code.

  BOOL Globals :: IsUsbDevice (wchar_t characters) {wchar_t volumeAccessPath [] = L "\\\. \ x:"; VolumeAccessPath [4] = Letters; Handle DeviceHandle = Create File W (Volume Access, 0, // Disk FILE_SHARE_READ | // SHARE MODEL FILE_SHARE_WRITE, NULL, // Default security attributes OPEN_EXISTING, // Disposition 0, // file attribute zero) is not reached; // Do not copy file properties if (device constellation == INVALID_HANDLE_VALUE) // can not close the drive {CloseHandle (deviceHandle); return false); } // Setup query STORAGE_PROPERTY_QUERY query; Meset (& amp; query; 0, sizeof (query)); Query Property id = storage deviceproperty; Query.QueryType = PropertyStandardQuery; // problem query DWORD bytes; // STORAGE_DEVICE_DESCRIPTOR devad; STORAGE_BUS_TYPE bus type = BusTypeUnknown; Four outbuffs [1024] = {0}; // Very good, usually about 100 bytes PSTORAGE_DEVICE_DESCRIPTOR pDevDesc = (PSTORAGE_DEVICE_DESCRIPTOR) outbuff; PDevDesc-> Size = OutBuf; If (DeviceIoControl (DeviceHandle, IOCTL_STORAGE_QUERY_PROPERTY, & amp; Query, Size (STORAGE_PROPERTY_QUERY), pDevDesc, pDevDesc-> Size, and Bytes, NULL) {busType = pDevDesc- & gt; BusType; } Else {// retrieve system error message for final error code ..........} CloseHandle (device handles); Return BusTypeUsb == bus type; }  

I am implementing my program as an administrator.

Any help would be greatly appreciated.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -