Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Win32: accessing device and partition information

81 views
Skip to first unread message

Martin Mertens

unread,
May 17, 2008, 5:42:42 AM5/17/08
to
Hello,

is there any API or TCL package that helps to access device and
partition information using the Win32 syntax, for example something like

"drive letter f: corresponds to \Device\Harddisk2\Partition1 which has
the size of 128 GB"

or

"at the moment, the following harddisks and partitions are available:
\Device\Harddisk1\Partition1, \Device\Harddisk2\Partition2, ..."

The lowest level of accessing file information that I found - using the
file command - is the level of drive letters, which of course makes
sense to keep system independent.

If there is no package for this issue - is there a sensefull exec call
(Win XP) that could help me?

Thanks a lot!

Martin

Helmut Giese

unread,
May 17, 2008, 7:46:11 AM5/17/08
to
On Sat, 17 May 2008 11:42:42 +0200, Martin Mertens
<martin-...@gmx.de> wrote:

>Hello,
>
>is there any API or TCL package that helps to access device and
>partition information using the Win32 syntax, for example something like
>
>"drive letter f: corresponds to \Device\Harddisk2\Partition1 which has
>the size of 128 GB"
>
>or
>
>"at the moment, the following harddisks and partitions are available:
>\Device\Harddisk1\Partition1, \Device\Harddisk2\Partition2, ..."

Hello Martin,
the TWAPI package (see http://wiki.tcl.tk/9886) offers an easy access
to the Windows API.
Now, how to obtain the information you want using Windows' API I have
no idea. If you don't get an answer here, I suggest turning to a
Windows compiler specific news group (Borland, Microsoft), ask there
which system calls to use and with this info use TWAPI to perform the
necessary calls.
HTH
Helmut Giese

pal...@yahoo.com

unread,
May 17, 2008, 8:28:11 AM5/17/08
to
Using twapi,

(ashok) 3 % ::twapi::get_mounted_volume_name c:
\\?\Volume{ebf51b60-c651-11d9-ad77-806d6172696f}\
(ashok) 4 % twapi::get_volume_info c: -device
-device {{\Device\HarddiskVolume2}}

Use twapi::find_logical_drives to get drive letters.

Note this will not give you information about partitions that are not
visible to Windows (e.g. unformatted).

/Ashok

pal...@yahoo.com

unread,
May 17, 2008, 8:30:24 AM5/17/08
to
Forgot to mention,

get_volume_info c: -size will give size information.
Also, the -device option actually returns a list. The first element is
the device. See the docs for details.

Martin Mertens

unread,
May 17, 2008, 12:59:23 PM5/17/08
to
Thanks Helmut Giese and thanks to thanks Ashok, that's exactly what I
was looking for.

Helmut Giese schrieb:

Darren New

unread,
May 21, 2008, 1:36:35 PM5/21/08
to
pal...@yahoo.com wrote:
> Note this will not give you information about partitions that are not
> visible to Windows (e.g. unformatted).

You can, however, read and parse the partition table on your own, if
it's an MBR partition table. Open {\Device\HarddiskVolume2} for read and
read in exactly 512 bytes, and you'll get the boot record, which
includes the partition table.

--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."

pal...@yahoo.com

unread,
May 21, 2008, 2:35:01 PM5/21/08
to
If you are willing to build your own twapi from cvs, you could also do
this

(base) 67 % get_volume_info c: -extents
-extents {{-startingoffset 57576960 -disknumber 0 -extentlength
75960460800}}

and

(base) 68 % twapi::_kl_print [lindex [get_physical_disk_info {\\.
\PhysicalDrive0} -layout] 1]
-partitionstyle: mbr
-partitioncount: 4
-partitions: {-hiddensectors 63 -partitionnumber 1 -startingoffset
32256 -partitionstyle mbr -recognizedpartition 1 -partitiontype 0xde -
rewritepartition 0 -partitionlength 57544704 -bootindicator 0} {-
hiddensectors 112455 -partitionnumber 2 -startingoffset 57576960 -
partitionstyle mbr -recognizedpartition 1 -partitiontype 0x07 -
rewritepartition 0 -partitionlength 75960460800 -bootindicator 1} {-
hiddensectors 148472730 -partitionnumber 3 -startingoffset 76018037760
-partitionstyle mbr -recognizedpartition 1 -partitiontype 0xdb -
rewritepartition 0 -partitionlength 4005711360 -bootindicator 0} {-
hiddensectors 0 -partitionnumber 0 -startingoffset 0 -partitionstyle
mbr -recognizedpartition 0 -partitiontype 0x00 -rewritepartition 0 -
partitionlength 0 -bootindicator 0}
-signature: 1101734678

This is not in the released twapi distribution though as I don't (yet)
have gpt formatted disks to test against.

/Ashok

On May 21, 10:36 pm, Darren New <d...@san.rr.com> wrote:

0 new messages