DeviceIoControl fails with opertion IOCTL_DISK_GET_DRIVE_LAYOUT
Hi I am trying to get the drive name(d:\,f:\) with DeviceIoControlfunction,
but it fails with error 5= Access is denied.
i am working with vista SP1,any way to to correct this error ?
if i will call the function with IOCTL_DISK_GET_DRIVE_GEOMETRY it will work
GREAT.
any reason why it fails if i used this operation:IOCTL_DISK_GET_DRIVE_LAYOUT
HERE IS THE CODE:
PARTITION_INFORMATION pdg;
hDevice = CreateFile(physicalDrive, // drive
0, // no access to the drive
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
{
return (FALSE);
}
bResult = DeviceIoControl(hDevice, // device to be queried
IOCTL_DISK_GET_DRIVE_LAYOUT, // operation to perform
NULL,
0, // no input buffer
&pdg,
sizeof(pdg), // output buffer
&junk, // # bytes
returned
(LPOVERLAPPED) NULL); // synchronous I/O
if(! bResult)
{
win = GetLastError();
}