How to convert a returned DWORD value in Python?

1.1k Views Asked by At

I'm working for the first time with ctypes to import DLLs. The DLL which I've imported contains a function which return a DWORD value. How can I convert this DWORD value?

for other functions which takes WORD arguments values I tried something like this (found in stack overflow).

from ctypes import *
my_dll = ctypes.windll.LoadLibrary (r"C:\\Users\\Mimouni\\Documents\\FFT_python\\Sense2020Dll.dll")
py_DLL_Acquire_Spectrum = my_dll.DLL_Acquire_Spectrum
py_DLL_Acquire_Spectrum.argtypes = [POINTER(c_double),POINTER(c_double),POINTER(c_double)]
py_DLL_Acquire_Spectrum.restype = None
pdblWavelength = (c_double)(my_dll.DLL_Get_Pixel_Count()) 
pdblPower = (c_double)(my_dll.DLL_Get_Pixel_Count())
pdblTemperature = (c_double)(0)
py_DLL_Acquire_Spectrum(pdblWavelength,pdblPower,pdblTemperature)

How can I use wintypes for returned values?

Thank you in advance.

1

There are 1 best solutions below

3
Jakub Šolín On

If you have a variable x of type DWORD (which is just an alias for ctypes.c_ulong), you can just use a.value to get its int value.