views:

480

answers:

2

Has anyone found a version of pywin32 for python 3.x? The latest available appears to be for 2.6.

Alternatively, how would I "roll my own" windows API calls in Python 3.1?

+5  A: 

You should be able to do everything with ctypes, if a bit cumbersomely.

Here's an example of getting the "common application data" folder:

from ctypes import windll, wintypes

_SHGetFolderPath = windll.shell32.SHGetFolderPathW
path_buf = wintypes.create_unicode_buffer(255)
csidl = 35
_SHGetFolderPath(0, csidl, 0, 0, path_buf)
print(path_buf.value)

Result:

C:\Documents and Settings\All Users\Application Data
Ryan Ginstrom
Cool! I will have a play with that too.
Blorgbeard
+4  A: 

There are pywin32 available for 3.0. Python 3.1 was release two days ago, so if you need pywin32 for that you either need to wait a bit, or compile them from source.

http://sourceforge.net/project/showfiles.php?group_id=78018&package_id=79063

Lennart Regebro
Ah I see! It seems I fail at reading comprehension ("This project is now being hosted at sourceforge - there may be later versions available than referenced on this page")
Blorgbeard