I am trying to take a provided DLL file from a software SDK and create a python wrapper so to integrate it with the rest of my code base. I have followed quite a few guides online, and still having no luck.
The current Python code I have is:
from ctypes import *
from ctypes.wintypes import HWND
import os
class OptistarDLL(object):
dll_path = 'OSDS142MRT.dll'
with open(dll_path) as thefile:
pass
_dll = WinDLL(dll_path)
init_library = _dll['OSDS142M_Initialize']
init_library.restype = c_int
init_library.argtypes = (c_int, c_bool, HWND, c_bool, c_int)
class OpticstarControl(object):
def __init__(self):
err = OptistarDLL.init_library(c_int(0), c_bool(False), HWND(0), c_bool(False), c_int(0))
if err != 0:
raise Exception("Doom")
The SDK documentation I am using provides this as the header for the function:
DLLDIR int OSDS142M_Initialize(int iModel, bool bOutVid, HWND hwOutVid, bool bStarView, int iRt);
And the example PDF gives:
OSDS142M_Initialize(1, false, 0, true, 0);
Initialisation currently gets me only
ValueError: Procedure probably called with too many arguments (20 bytes in excess)
I have read, but not understood, about the WinDLL vs CDLL, and the loading of the DLL fails when I change to CDLL. I have also seen in all the guides that the headers in them have DLLEXPORT and mine has DLLDIR, and I don't know if this is a concern.
Does anyone have any ideas?