system32 directory

Tim Golden mail at timgolden.me.uk
Thu Mar 6 03:42:38 EST 2008


Robert Dailey wrote:
> Hi,
> 
> Is there a way to get the System32 directory from windows through python?
> For example, in C++ you do this by calling GetSystemDirectory(). Is there an
> equivalent Python function for obtaining windows installation dependent
> paths?

<fishing advice>
First thing to do when asking "How do I do X in Python under Windows?"
is to stick -- python X -- into Google and you get, eg:

http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32api__GetSystemDirectory_meth.html

which suggests that the win32api module from the pywin32 modules has
the function you need.
</fishing advice>

And sure enough...

<dump>
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> import win32api
 >>> win32api.GetSystemDirectory ()
'C:\\WINDOWS\\system32'
 >>>
</dump>

TJG



More information about the Python-list mailing list