Task:
List all available drive partitions with their volumes, parameteres
(most important partition size, to calculate partition sector count)
This must be a windows application.
PartitionSectorCount = PartitionSize / 512;
I used the DeviceIoControl(...) API function width
IOCTL_DISK_GET_DRIVE_LAYOUT parameter to list
all available partitions on specified disk.
It works but there is one problem.
It returns all partitions by their numbers, there is no
information about drive letter.
How can I idenitfy partition drive letter?
I need that because the drive letter of partition is
key to open it with CreateFile(...) API
function to have direct access to that portion of drive.
There is another solution.
is to
1. open direct access to all portions of drive
2. read MBR (master boot record) which contains main information
about partitions.
I don't like this solution because it's dangerous.
Error in my application may destroy file systems on entire disk drive.
That's why I preffer to have full access only to some portion of
drive, only to one partition to prevent any damage.
__________________
Regards, Aram
I need to do something with this to finish my degree thesis.
I'm creating my own file system.
Entering the drive letter and it's number to get
direct access to the partition of the disk drive is
not good, I don't wan't to imagine what will
happen if the drive letter will not correspond to
it's number by user mistake ...
Здравствуйте, BlackCode, Вы писали:
BC>Task: BC>List all available drive partitions with their volumes, parameteres BC>(most important partition size, to calculate partition sector count)
BC>This must be a windows application.
BC>PartitionSectorCount = PartitionSize / 512;
BC>I used the DeviceIoControl(...) API function width BC>IOCTL_DISK_GET_DRIVE_LAYOUT parameter to list BC>all available partitions on specified disk.
BC>It works but there is one problem.
BC>It returns all partitions by their numbers, there is no BC>information about drive letter.
BC>How can I idenitfy partition drive letter?
BC>I need that because the drive letter of partition is BC>key to open it with CreateFile(...) API BC>function to have direct access to that portion of drive.
BC>There is another solution. BC>is to BC>1. open direct access to all portions of drive BC>2. read MBR (master boot record) which contains main information BC>about partitions.
BC>I don't like this solution because it's dangerous. BC>Error in my application may destroy file systems on entire disk drive.
BC>That's why I preffer to have full access only to some portion of BC>drive, only to one partition to prevent any damage. BC>__________________ BC>Regards, Aram
Those APIs are depenending on partitions file system.
Those functions work when there is known file system on specified partition,
Those APIs will fail if there is no, or there is unknown file system on specified
partition.
I tried them all before I made this topic.
I need file system independent APIs.
I found such APIs, but they present only on Windows 2003 Server and later versions of windows.