Code: Select all
Structure DISK_GEOMETRY
Cylinders.q
MediaType.l
TracksPerCylinder.l
SectorsPerTrack.l
BytesPerSector.l
EndStructure
Structure DISK_GEOMETRY_EX
pp1.DISK_GEOMETRY
DiskSize.q
byte.b[1];
EndStructure
pp.DISK_GEOMETRY_EX
#IOCTL_DISK_BASE = 7
#METHOD_BUFFERED = 0
#FILE_ANY_ACCESS = 0
Procedure.l CTL_CODE(DeviceType, Function, Method, Access)
ProcedureReturn ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)
EndProcedure
IOCTL_DISK_GET_DRIVE_GEOMETRY_EX = CTL_CODE(#IOCTL_DISK_BASE, $28, #METHOD_BUFFERED, #FILE_ANY_ACCESS)
hDevice = CreateFile_("\\.\PhysicalDrive0", #GENERIC_READ,#FILE_SHARE_READ,0,#OPEN_EXISTING,0,0)
If hDevice
DeviceIoControl_(hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,0,0,@pp,SizeOf(pp),@bytesret, 0)
EndIf
CloseHandle_(hDevice)
Debug pp\Disksize / (1024*1024*1024) ;in gb
;and other
Debug pp\pp1\cylinders
Debug pp\pp1\TracksPerCylinder
Debug pp\pp1\SectorsPerTrack
Debug pp\pp1\BytesPerSector
