BlackCode
|
|
|
|
|
Рег.: 25.11.2005
|
Сообщений: 131
|
Из: Moscow, Russia
|
Рейтинг: 0
|
|
Listing available drive partitions
04.12.2005 04:40
|
|
|
У меня когда то была проблема когда писал дипломную работу. Эту проблему мне решить не удалось. Я вразных форумах мира писал об этом но полезного ответа не было =(
Может тут кто ни будь знает что делать. И заранее прошу прощения за английский, просто сделал копи паст, если необходимо я все переведу, хотя думаю что у вас с английским проблем быть не должно.
----
Task: List all available drive partitions with their volumes, parameteres (most important size to calculate partition sector count)
This must be windows application.
PartitionSectorCount = PartitionSize / 512;
I used 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 drive letter of partition is a key to open it with CreateFile(...) 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 operating system.
That's why I preffer to have full access only to some portion of drive only to one partition to prevent any damage.
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 ...
someone told me to use GetFileSize(...)... and something more.
In this case it doesn't work. I even can tell why.
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 need file system independent APIs.
I found such APIs, but they present only on Windows 2003 Server and later versions of windows.
I tried them all before I made this topic.
Редактировал BlackCode (04.12.2005 04:44)
|
never get enough - - - - Regards, Aram |
|
dimich
|
Pooh-Bah
|
|
|
|
Рег.: 15.04.2004
|
Сообщений: 2354
|
Из: Б-1422лев
|
Рейтинг: 2
|
|
Re: Listing available drive partitions
[re: BlackCode]
04.12.2005 15:57
|
|
|
ботай WMI, такие классы как: Win32_DiskDrive Win32_DiskDriveToDiskPartition Win32_DiskPartition Win32_LogicalDiskToPartition Win32_LogicalDisk
|
|
l0st
|
ГосДеп
|
|
|
|
Рег.: 11.11.2005
|
Сообщений: 7674
|
|
Рейтинг: 3076
|
|
Re: Listing available drive partitions
[re: BlackCode]
04.12.2005 17:13
|
|
|
В ответ на:
I don't like this solution because it's dangerous. Error in my application may destroy operating system.
Интересно, как ты нанесешь вред, только читая информацию с хдд?
|
коммунист |
|
BlackCode
|
|
|
|
|
Рег.: 25.11.2005
|
Сообщений: 131
|
Из: Moscow, Russia
|
Рейтинг: 0
|
|
Re: Listing available drive partitions
[re: l0st]
04.12.2005 18:49
|
|
|
Quote:
Интересно, как ты нанесешь вред, только читая информацию с хдд?
задача была такова Создать собственную систему управления файлами. Читая MBR для данного диска я должен был определить откуда начинаются и кончаются все primary разделы. В таком случае мой вызов CreateFile-а даст мне доступ не к отдельному разделу как хотелось бы, а к всему диску. Следовательно моя программа может случайно нарушить эти границы и записать какие-то данные вне предполагаемого раздела.
Речь тут идет о прямом доступе.
Редактировал BlackCode (04.12.2005 18:51)
|
never get enough - - - - Regards, Aram |
|
BlackCode
|
|
|
|
|
Рег.: 25.11.2005
|
Сообщений: 131
|
Из: Moscow, Russia
|
Рейтинг: 0
|
|
Re: Listing available drive partitions
[re: dimich]
04.12.2005 18:54
|
|
|
WMI =) попробую хорошо звучит, ведь программа Disk Manager этого рода
Да но WMI не поддерживается ранними версиями windows, тоесть ниже 2000-ого насколько я знаю, хотя это уже не так важно, но отсюда следует, что существует и другой способ.
Редактировал BlackCode (04.12.2005 18:56)
|
never get enough - - - - Regards, Aram |
|