_DD said:
Thanks, Louis. I should have specified...I was looking for the
drive's 'hardware' serial number. The above looks like the serial
that's assigned as the drive is formatted.
I think I wrote a program to do the latter at one time, though not in
Python. I took a very cursory look at Python, and to be honest, the
syntax did not appeal to me at the time. I guess it's from years of
programming with curl-braces. Is it worth learning if one already has
a background in structured programming?
If so, and if it's no problem, please post your code and I'll take a
look on the way to learning some Python.
Thanks!
With the exception of "Hello world!" in C and Java, Python is the only
language I know. (Unless you count Basic.) The one thing I have found is
that you can whip up a quick utility in no time. I am not a programmer, but
even I can get some work done in a hurry. You might take a look at the
tutorial links at python.org. Once you get past the fact that indentation is
significant, you'll find it quite easy to learn. By the way, I think those
funny looking, randomly placed curly braces are what steered me toward
Python. The indentation or Python forces the structure of your program to
be consistent and makes it easy to read other people's code. Just my
opinion.
Louis
------------------------------------------------------------
import win32api
print
try:
cName = win32api.GetComputerName()
except:
cName = 'Computer Name Unknown'
print 'Serial numbers for all drives on %s:' %\
(cName)
print
count=0
for i in range(26):
dLetter = chr(i + 97) + ':\\'
try:
x = win32api.GetVolumeInformation(dLetter)
volser = int(x[1])
if volser < 0:
volser = 4294967296 - abs(volser)
hexser = hex(volser).strip('L').upper()[2:]
while len(hexser) < 8:
hexser = '0' + hexser
print 'Serial # for drive %s is %4s %4s' %\
(dLetter[:2].upper(), hexser[0:-4],\
hexser[-4:])
count+=1
except:
pass
print
print '%s volume(s) found on %s' % (count, cName)
------------------------------------------------------------