Armenian Knowledge Base  

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

Reply
 
LinkBack Thread Tools
Old 12.02.2005, 18:57   #1
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 32
Posts: 16
Downloads: 0
Uploads: 0
Reputation: 0 | 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
Reply With Quote
Old 27.03.2005, 14:25   #2
Пламя звезды, пламя свечи
 
Join Date: 07 2004
Location: T
Age: 40
Posts: 8
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

Isk kareli a hetaqrqrvel inchi hamara petq?
Reply With Quote
Old 13.04.2005, 07:57   #3
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 49
Posts: 104
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

GetLogicalDrives()
http://support.microsoft.com/default...b;en-us;193623
Reply With Quote
Old 14.04.2005, 08:07   #4
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 32
Posts: 16
Downloads: 0
Uploads: 0
Reputation: 0 | 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.
Reply With Quote
Old 14.04.2005, 08:12   #5
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 32
Posts: 16
Downloads: 0
Uploads: 0
Reputation: 0 | 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.
Reply With Quote
Old 14.04.2005, 10:22   #6
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 49
Posts: 104
Downloads: 0
Uploads: 0
Reputation: 0 | 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 ?
Reply With Quote
Old 14.04.2005, 10:40   #7
Дошкольник
 
Join Date: 03 2003
Location: 2A
Age: 49
Posts: 104
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

А вообще эта информация должна быть в registry. Смотри в сторону PDH (Performance Data helper) interface.
Reply With Quote
Old 14.04.2005, 11:55   #8
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 32
Posts: 16
Downloads: 0
Uploads: 0
Reputation: 0 | 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.
Reply With Quote
Old 14.04.2005, 11:57   #9
incomer
 
BlackCode's Avatar
 
Join Date: 02 2005
Location: Yerevan
Age: 32
Posts: 16
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Wink

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

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 10:01.


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