[python-win32] Volume Serial Number [SOLVED]
Rickey, Kyle W
Kyle.Rickey at bakerhughes.com
Fri May 16 20:18:49 CEST 2008
Thanks to all for your responses.
I tried both methods from each Tim. :)
> Yes, actually, it does. The second item in the tuple it returns is
the
> VSN as a 32-bit binary value.
Ahh, now I understand where I messed up, your code example enlightened
me.
> WMI to the rescue?
> <code>
> import wmi
>
> for volume in wmi.WMI ().Win32_LogicalDisk ():
> print volume.Caption, "=>", volume.VolumeSerialNumber
>
> </code>
This example also worked quite well. In addition to that there's lots of
juicy information available from the 'volume' object. Thanks for that!
> If you want the SN from the drive manufacturer, you will need to issue
an > IOCTL ATA Passthrough command which sends the ATA Identify Device
command > to the drive. Unless the Winapi has a wrapper for that
functionality, you > can't do that via Python.
Thanks for that as well, although not what I was looking for, I'll save
that for a rainy day. :)
Just for message consistency, I've reposted Tim Robert's example below:
def UnsignedHex( v ):
if v >= 0: return '%08X' % v
return '%08X' % (0x100000000 + v )
print UnsignedHex( win32api.GetVolumeInformation('C:\\')[1] )
Thanks again to everyone for your help.
-Kyle Rickey
-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Tim Golden
Sent: Friday, May 16, 2008 12:45 PM
Cc: python-win32 at python.org
Subject: Re: [python-win32] Volume Serial Number
Rickey, Kyle W wrote:
> How do I get the volume serial number for a drive? For example in the
> cmd prompt issuing this:
WMI to the rescue?
<code>
import wmi
for volume in wmi.WMI ().Win32_LogicalDisk ():
print volume.Caption, "=>", volume.VolumeSerialNumber
</code>
TJG
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32
More information about the python-win32
mailing list