Справочник функций

Ваш аккаунт

Войти через: 
Забыли пароль?
Регистрация
Информацию о новых материалах можно получать и без регистрации:

Почтовая рассылка

Подписчиков: -1
Последний выпуск: 19.06.2015

Listing available partitions

7.3K
27 ноября 2004 года
BlackCode
16 / / 11.10.2004
Task:
List all available drive partitions with their volumes, parameteres
(most important size to caluculate 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?
7.3K
27 ноября 2004 года
BlackCode
16 / / 11.10.2004
I need that because drive letter of partition is
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, file system on other partitions...

That's why I preffer to have full access only to some portion of
drive only to one partition to prevent any damage.
6.4K
04 декабря 2004 года
DeVid
1 / / 20.12.2003
Цитата:
Originally posted by BlackCode
Task:
List all available drive partitions with their volumes, parameteres
(most important size to caluculate 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?


So.
* The 1st variant:
There is no problem, if you'll get access to this drive by the number of this drive. ;-) E.g., if you want to read file 'text.txt' from drive D:\, MY_DOC directory:
D:\MY_DOC\text.txt
you should set the current drive by API/INT 13h (if DOS) by drive number and then change directory to MY_DOC. Or set drive by number and then simply read this file by path MY_DOC\text.txt.
* The 2nd variant:
Get information, which kind of letters are available on your machine. Then create array to correlate drive letters to drive number. It is simply, because numbers of disk drives go consistently. So, if letters are C,D,X,Z, their drive numbers are 3,4,5,6 accordingly. But if letters are A,C,D,X, drive numbelrs will be 1,3,4,5 (disk B excepted).

Sorry for poor english. :)
If you want to know, which kind of letter is available on your machine, you should:

7.3K
10 января 2005 года
BlackCode
16 / / 11.10.2004
Devid.

Sorry for late answer.

Цитата:
There is no problem, if you'll get access to this drive by the number of this drive.



how can I get access volume by it's number in windows ?

Цитата:
Get information, which kind of letters are available on your machine.



how ?

Цитата:
So, if letters are C,D,X,Z, their drive numbers are 3,4,5,6 accordingly



I think you are wrong,
in Windows NT it's not always as you think.

Реклама на сайте | Обмен ссылками | Ссылки | Экспорт (RSS) | Контакты
Добавить статью | Добавить исходник | Добавить хостинг-провайдера | Добавить сайт в каталог