I need to get a capacity of inserted DVD disk.
DeviceIoControl function call with IOCTL_DISK_GET_DRIVE_GEOMETRY_EX parameter writes 4128768 bytes as a size of DVD what, obviously, is wrong result. Code was taken from https://learn.microsoft.com/en-us/windows/win32/devio/calling-deviceiocontrol.
Another solution was to determine disk read or write speed via ckMMC lib's Device interface and return size depending on it's type. But it isn't reliable solution since speed can vary on different CD/DVD drives.
Maybe, I'm missing something with DeviceIoControl usage and it can return me correct result or there exists better approach to calculate DVD disk's capacity.
There is a field
DiskSize
in DVD_LAYER_DESCRIPTOR, which I was looking for.Firstly, we should open drive with correct permissions.
Be careful with
devicePath
, it should be in Win32 Device Namespace. After getting drive handle, with the help of DeviceIoControl getDVD_LAYER_DESCRIPTOR
structure.dvdReadStruct.Format
determines which structure will be written tobuffer
. For example, if you will setDvdManufacturerDescriptor
, function writes DVD_MANUFACTURER_DESCRIPTOR to buffer.