ctypes, GetWindowLongPtr

Henry Baxter henry.baxter at gmail.com
Fri Jan 11 21:14:54 EST 2008


Hello,

I have been happily using ctypes for a while to do win32 programming. I use
the Microsoft documentation to understand the function, then call it with
the help of ctypes.

The problem is that the docs says user32.dll has GetWindowLongPtr, but
ctypes can't find it using windll.user32.GetWindowLongPtrA or
windll.user32.GetWindowLongPtrW or windll.user32.GetWindowLongPtr. Errors
look like this:

Traceback (most recent call last):
  File "Z:\experiments\windowsapp3.py", line 106, in <module>
    GetWindowLongPtr = windll.user32.GetWindowLongPtrA
  File "C:\Python25\lib\ctypes\__init__.py", line 353, in __getattr__
    func = self.__getitem__(name)
  File "C:\Python25\lib\ctypes\__init__.py", line 358, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'GetWindowLongPtrA' not found

I have the same problem with the SetWindowLongPtr function.

I can use plenty of other functions (GetParent, CreateWindowExA,
DefWindowProcA, and etc) but not these ones.


I don't understand what goes on with ctypes under the hood really, so my
troubleshooting abilities at this point are quite lacking! I would
appreciate any help you could offer.


Thanks!


-- 
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080111/8f49608d/attachment.html>


More information about the Python-list mailing list