Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > C/C++

Reply
 
Thread Tools

Listing available partitions, problem =(
Old 12.02.2005, 18:57   #1
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 39
Posts: 16
Rep Power: 0
Question Listing available partitions, problem =(

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

Old 27.03.2005, 13:25   #2
Пламя звезды, пламя свечи
 
Join Date: 07 2004
Location: T
Age: 47
Posts: 8
Rep Power: 0
Default

Isk kareli a hetaqrqrvel inchi hamara petq?

Old 13.04.2005, 06:57   #3
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 56
Posts: 104
Rep Power: 0
Default

GetLogicalDrives()
http://support.microsoft.com/default...b;en-us;193623

Old 14.04.2005, 07:07   #4
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 39
Posts: 16
Rep Power: 0
Default

Quote:
Originally Posted by Mr.M
Isk kareli a hetaqrqrvel inchi hamara petq?
Diplomayin ashxatanqsa, grum em im windows-i tak ashxatox fayleri,
tvyalneri, xekavarman hamakarg.

Old 14.04.2005, 07:12   #5
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 39
Posts: 16
Rep Power: 0
Default

Quote:
Originally Posted by armeng
Ok, I have a the list of the available partitions drive letter,
how I can identify it's size ?

I this case GetFileSize(...) will not work.

Old 14.04.2005, 09:22   #6
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 56
Posts: 104
Rep Power: 0
Default

Quote:
Originally Posted by BlackCode
Ok, I have a the list of the available partitions drive letter,
how I can identify it's size ?

I this case GetFileSize(...) will not work.
GetDiskFreeSpaceEx ?

Old 14.04.2005, 09:40   #7
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 56
Posts: 104
Rep Power: 0
Default

А вообще эта информация должна быть в registry. Смотри в сторону PDH (Performance Data helper) interface.

Old 14.04.2005, 10:55   #8
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 39
Posts: 16
Rep Power: 0
Default

Quote:
Originally Posted by armeng
GetDiskFreeSpaceEx ?
No no.

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.

Old 14.04.2005, 10:57   #9
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 39
Posts: 16
Rep Power: 0
Wink

Quote:
Originally Posted by armeng
А вообще эта информация должна быть в registry. Смотри в сторону PDH (Performance Data helper) interface.
Попробую.
Reply




Реклама:
реклама

All times are GMT. The time now is 22:25.
Top

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.