title: How to create a Python wrapper for a DLL library
body: <p>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.</p>
  
  <p>The current Python code I have is:</p>
  
  <pre class="lang-py prettyprint-override"><code>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")
  </code></pre>
  
  <p>The SDK documentation I am using provides this as the header for the function:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>DLLDIR int OSDS142M_Initialize(int iModel, bool bOutVid, HWND hwOutVid, bool bStarView, int iRt);
  </code></pre>
  
  <p>And the example PDF gives:</p>
  
  <pre><code>OSDS142M_Initialize(1, false, 0, true, 0);
  </code></pre>
  
  <p>Initialisation currently gets me only</p>
  
  <pre><code>ValueError: Procedure probably called with too many arguments (20 bytes in excess)
  </code></pre>
  
  <p>I have read, but not understood, about the <code>WinDLL</code> vs <code>CDLL</code>, and the loading of the DLL fails when I change to <code>CDLL</code>. I have also seen in all the guides that the headers in them have <code>DLLEXPORT</code> and mine has <code>DLLDIR</code>, and I don't know if this is a concern.</p>
  
  <p>Does anyone have any ideas?</p>