![]() |
| Home |
|
|
Function RTFGetPartitionInfoRTFGetPartitionInfo returns information about a partition or physical disk:
int RTFGetPartitionInfo(const char * DriveName,
RTFPartitionInfo * PartitionInfo);
ParametersDriveNameMust be a valid file name (for example, a root directory such as "C:\"), a logical drive name ("\\.\C:"), or a physical disk name ("\\.\PHYSICALDRIVE0"). If the name refers to a physical disk file, the returned partition information applies to the whole disk, not just a single logical drive. PartitionInfoMust point to a structure RTFPartitionInfo declared in Rtfiles.h:
typedef struct {
RTFPartitionRecord Partition;
DWORD PartitionSector;
int PhysicalDiskIndex;
UINT BytesPerSector;
BYTE MediaDescriptor;
BYTE Reserved;
short DeviceListIndex;
} RTFPartitionInfo;
Structure RTFPartitionRecord is defined as:
typedef struct {
BYTE BootIndicator, // 0x80 for bootable, 0 otherwise
StartHead, // 0 based
StartSector, // 1 based, bits 0-5,
StartTrack, // 0 based, bits 0-7, take bits 8,9 from StartSector
OSType, // FAT-12: 1, FAT-16: 4, 6, 14, FAT-32: 11, 12
EndHead, // see StartHead
EndSector, // see StartSector
EndTrack; // see StartTrack
DWORD RelativeSector, // offset to first sector of partition data
// for primary partitions, this is the absolute
// LBA of the boot sector
Sectors; // number of sectors in partition
} RTFPartitionRecord;
Please note that actual values must be calculated as follows: ActualStartSector = StartSector & 63; ActualStartTrack = StartTrack | ((StartSector & 0xC0) << 2); ActualEndSector = EndSector & 63; ActualEndTrack = EndTrack | ((EndSector & 0xC0) << 2); For large hard disks, the EndTrack value may be incorrect, because it is limited to 1024 cylinders. If you need to calculate the size of a disk or partition, rely on field Sectors. For ISO 9660 disks, only field Sectors is meaningful. return valueIf the function succeeds, the return value is RTF_NO_ERROR and the structure is filled as described below. If the function fails, the return value is a negative error code.
|