[python-win32] Dereferencing lParam pointer

Ulrich Mierendorff ulrich.mierendorff at gmx.net
Thu Feb 25 18:15:53 CET 2010


Mark Hammond wrote:
> On 25/02/2010 10:01 AM, Tim Roberts wrote:
>>> but I am not sure. Is there a way to get the array/list?
>>
>> You will have to use a package like ctypes to do that.  Something 
>> like this:
>>
>> lst = ctypes.cast(lParam, ctypes.POINTER(ctypes.c_int))
>> print lst[0]
>> print lst[1]
>
> Or use something like win32gui.PyGetMemory and the struct module (same 
> result, different modules)
Thanks! This also works. I am now using the following solution

extr = '@' + 'l'*wParam
bytes = struct.calcsize(extr)
parts = win32gui.PyGetMemory(lParam, bytes)
parts = list(struct.unpack(extr, parts))

-Ulrich


More information about the python-win32 mailing list