Win32 API's missing/incomplete?
Thomas Heller
theller at python.net
Fri Jan 31 03:48:12 EST 2003
"Ixokai" <usenet at ixokai.net> writes:
> Hi folks.
>
> I was trying to solve a mysterious problem in my program when I decided to
> try a more direct route to os.system("subst ..") in my application.. so I
> did some digging, and found win32file.DefineDosDrive.
>
> Awesome. However, it has two problems... First, there is no QueryDosDrive
> that i can find, which is sorta important for my purposes..
Again, ctypes to the rescue:
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import windll, c_string
>>> kernel32 = windll.kernel32
>>> bytes = kernel32.QueryDosDeviceA(None, buf, len(buf))
>>> print bytes
4782
>>> buf.raw[:bytes].split("\000")
['NDIS', 'DISPLAY1', 'DISPLAY2', '{F9CF61E8-01A6-4C5D-835B-E7FCDEEB0D60}',
(and so on)
> and Secondly, I
> can't see how to /undelete/ a drive totally, without knowing the path its
> set to.
>
> See, if you pass a "null" value to the function its susposed to delete
> whatever the latest path is that was stuck onto that drive.. but None, "",
> [], et al, are not valid params to DefineDosDrive.
>
> Anyone have any sugguested solutions? Thanks in advance.
Thomas
More information about the Python-list
mailing list