system32 directory

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Mar 6 23:01:46 CET 2008


En Thu, 06 Mar 2008 19:15:17 -0200, Robert Dailey <rcdailey at gmail.com>  
escribi�:

> On Thu, Mar 6, 2008 at 2:42 AM, Tim Golden <mail at timgolden.me.uk> wrote:
>>
>>  >>> import win32api
>>  >>> win32api.GetSystemDirectory ()
>> 'C:\\WINDOWS\\system32'
>
> I was aiming to figure out if the standard modules shipped with Python  
> could
> do this already before I started using 3rd party libraries. Thanks.

Use ctypes then:

py> from ctypes import *
py> windll.kernel32.GetSystemDirectoryA
<_FuncPtr object at 0x00A0F918>
py> GetSystemDirectory = windll.kernel32.GetSystemDirectoryA
py> buffer = create_string_buffer(260)
py> GetSystemDirectory(buffer, sizeof(buffer))
19
py> buffer.value
'C:\\WINDOWS\\system32'

-- 
Gabriel Genellina




More information about the Python-list mailing list