windows - How to create a Python wrapper for a DLL library -


I am trying to take a rendered DLL file from a software SDK and trying to create a python wrapper In order to integrate it with the rest of my code base I have followed a lot of guides online, and there is still no luck.

I have the current Python code: import from ctypes.wintypes from ctypes imported HWND import OS class OptistarDLL (object ): Dll_path = 'OSDS142MRT.dll' with open (dll_path) as thefile: passed _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) Category OpticstarControl (object): def __init __ (self): An = OptistarDLL.init_library (c_int (0), c_bool (false), HWND (0 ), C_bull (wrong), CIIT (0)) if mistake! = 0: Extend exceptions ("doom")

The SDK I am using provides the header for documentation functions:

  DLLDIR integer OSDS142M_Initialize (integer iModel, bool bOutVid, HWND hwOutVid, bool bStarView, IRT int);  

More examples give PDFs:

  OSDS142M_Initialize (1, false, 0, true, 0);  

Initially only me

  value error: possibly the process called with lots of arguments (more than 20 bytes)  

I have read about but have not understood about WinDLL vs cdll , and when I change into CDLL DLL Loading I have also seen in all the guides, which have DLLEXPORT in their header and my DLLDIR , and I do not know whether this concern Land.

Does anyone have any ideas?

The information given in the question is most likely, that DLL stdcall instead of cdecl uses your WinDLL to match the stdcall DLL. Instead of switching to the cdecl calling convention, use CDLL .

The error message corresponds to this. The difference in calling conventions is that the Kelly stack is cleanup in stdcall and the caller has been cleared on cdecl . The parameters consume 20 bytes on the stack, there are 5 parameters of 4 sizes. And ctypes push those parameters and hope to clean Kelly Stack. Those who do not do this because it is a cdecl function

The function is extremely complex in your call. You can type:

  err = OptistarDLL Init_library (0, false, 0, false, 0)  

Note that the example calls you quote will be written to match the different criteria that call:

< Pre err = OptistarDLL.init_library (1, false, 0, true, 0)

You should remove it code:

  open (Dll_path) as file: pass  

this time wasting In addition to no other purpose if the DLL is not present, then you will face soon failure.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -