Ctypes behave differenty on windows 2000 and windows XP
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Oct 3 03:46:43 EDT 2008
En Thu, 02 Oct 2008 10:17:01 -0300, <dudeja.rajat at gmail.com> escribió:
> Im facing a strange problem with ctypes module on windows 2000. I did not
> face this problem with the windows Xp.
>
> The problem is this code and specifically "c_long" which behave
> differently
> on win2000 and winxp
>
> from ctypes import *
> h = windll.LoadLibrary("C:\\Windows\\System32\\myDll.dll")
> print h
> ver = getattr(h, "myDll_GetVersion")
> versionArr = c_long * 4
> version = versionArr(0, 0, 0, 0)
> print ver(version)
> dllVersionStr = "v%d.%d.%d.%d" % tuple(version)
> print dllVersionStr
>
> The same code appears to work on windows xp with dllVersionStr printing
> as
> v1.3.5.0
> But on wIindows 2000 it prints v0.0.0.0
For myDll_GetVersion you should define its arguments and return type using
.argtypes and .restype - else ctypes assumes "int"
--
Gabriel Genellina
More information about the Python-list
mailing list