How to use deviceiocontrol function properly. Rate this: Please Sign up or sign in to vote. I think you might need FILESHAREREAD access to read the device serial number? This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL).
I am trying to find the serial number of a device. The only place i have been able to find the actual true serial number that is listed on the back of the device was here:this = 0x013419c8 {m_pszChangerPath=0x01341e50 '?sbp2#sony&vgp-xl1b&lun2#003060a100004128#{53f56310-b6bf-11d0-94f2-00a0c91efb8b}' m_hChanger=0xffffffff }
While debugging my code i found the serial number is: a100004128
I found the data from the following call:
HRESULT CChangerControl::OpenChanger()
{
m_hChanger = CreateFile(
m_pszChangerPath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
![Select Select](/uploads/1/2/6/5/126512813/840022874.png)
0,
NULL);
the data is in the m_pszChangerPath, field. Does anyone know a way for me to programatically get this serial number within the string.
I tried to get the Serial number from making an additional call to:
status = DeviceIoControl(
m_hChanger,
IOCTL_STORAGE_QUERY_PROPERTY,
![Deviceiocontrol Serial Number Deviceiocontrol Serial Number](http://s1.dmcdn.net/ZcdK/x240-Atj.jpg)
sizeof( STORAGE_PROPERTY_QUERY ),
&bOutputBuffer,
sizeof(bOutputBuffer),
&returnedLength,
NULL);
if (status false)
{
return 'ERROR:1234';
}
STORAGE_DEVICE_DESCRIPTOR *pDesc = (PSTORAGE_DEVICE_DESCRIPTOR) bOutputBuffer;
if (pDesc->SerialNumberOffset != 0)
return (PCHAR) ((PBYTE)pDesc + pDesc->SerialNumberOffset);
return 'OK';
}
When displaying this, it does not seem to be the real serial number. Can anyone help?