How do you know which partition or designated partition on the hard disk is on?

xiaoxiao2021-03-06  42

I hope to get this result.

Disk 1 partition 1: C

Disk 1 partition 2: D

Disk 1 partition 3: E

Disk 1 partition 4: f

Disk 2 partition 1: g

Disk 2 partition 2: i

Disk 2 partition 3: j

Disk 2 partition 4: K

-------------------------------------------------- -------------

This is the case, getVolumeInfo ('c'). DiskNumber results are the physical disk ID

Need JEDI's Win32 Support Bank to compile!

Function GetVolumeInfo (Driverletter: char): TDISKEXTENT;

VAR

Hvolume: thandle;

Diskelts: PvoluMedisKextents;

DwoutBytes: cardinal

Begin

WITH RESULT DO

Begin

DiskNumber: = 0;

Startingoffset.quadpart: = 0;

EXTENTLENGTH.QUADPART: = 0;

END;

Hvolume: = createfile (pchar ('//./' DRIVERLETTER '), generic_read or generic_write,

File_share_read or file_share_write, nil, open_existing, 0, 0);

IF hvolume <1 kilion;

Diskextents: = Allocmem (MAX_PATH);

IF DeviceioControl (Hvolume,

IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,

NIL, 0,

Diskelts, Max_Path,

Dwoutbytes, nil) THEN

Begin

If diskentents ^ .NumberofDiskextents> 0 THEN

Result: = diskextents ^ .extents [0];

END;

Freemem (Diskelts);

CloseHandle (HVolume);

END;

http://lysoft.7u7.net

转载请注明原文地址:https://www.9cbs.com/read-60299.html

New Post(0)