I have to different dlls exporting this functions (one function each dll):
dll1:
DECLDIR void getFrameworkVersion(int* pMajor, int* pMinor, int* pBugfix);
dll2:
void __stdcall getFrameworkVersion(int* pMajor, int* pMinor, int* pBugfix);
Im importing both dlls in python with no errors, and calling them with no errors either. However I'm getting wrong values
dll1 = cdll.LoadLibrary('dll1')
dll2 = oledll.LoadLibrary('dll2')
pMajor = pMinor = pbugFix = c_int()
dll1.getASTFrameworkVersion.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)]
#test.eval.restype = ctypes.c_double
dll1.getASTFrameworkVersion(byref(pMajor), byref(pMinor), byref(pbugFix))
astVersion = "AST Framework version: " + str(pMinor.value) + "." + str(pbugFix.value) + "." + str(pMajor.value)
dll2.getFrameworkVersion.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)]
dll2.getFrameworkVersion(byref(pMajor), byref(pMinor), byref(pbugFix))
asfVersion = "ASF Framework version: " + str(pMinor.value) + "." + str(pbugFix.value) + "." + str(pMajor.value)
I'm getting this output:
AST Framework version: 0.0.0
ASF Framework version: 14.14.14
pMajor = pMinor = bugFix = c_int()
is wrong: all three Python names are the same c_int
instance, so will contain the same value! What you're doing is equivalent to the following code in C:
int x;
getFrameworkVersion(&x, &x, &x);
So the fact that you get 0.0.0
is probably because the real result would end in .0
, which overwrites the previous two values.