title: Access Violation using Python Ctypes
body: <p>I am trying to import and use a function from a DLL using Pythons ctypes module, but I keep getting this error:</p>
  
  <blockquote>
  <pre><code>Windows Error: exception: access violation writing 0x0000002C
  </code></pre>
  </blockquote>
  
  <p>I've had a look at the other questions on similar topics on here, but none seem to be able to provide an answer that works.
  My current code is as follows:</p>
  
  <pre><code>from ctypes import *
  
  dll = "./WinlicenseSDK/WinlicenseSDK.dll"
  
  mydll = cdll.LoadLibrary(dll)
  
  name = c_char_p("A.N. Body")
  org = c_char_p("ACME")
  pcID = c_char_p("APC44567")
  zero = c_int(0)
  licenseKey = create_string_buffer("")    
  
  mydll.WLGenLicenseFileKey(HASH, name, org, pcID, zero, zero, zero, zero, zero, licenseKey)
  </code></pre>
  
  <p>Context: I'm investigating licensing techniques for a piece of software. The above function generates a license key from hashing the parameters.</p>
  
  <p>The last parameter for the WLGenLicenseFileKey is a string buffer that the generated key is written to.</p>
  
  <p>I tried setting the argtypes for the function with <code>mydll.WLGenLicenseFileKey.argtypes = ...</code> but this won't work as there is not a string buffer ctypes raw type as there is for strings, ints, floats etc.</p>
  
  <p>Can anybody tell me where I am going wrong?</p>
  
  <p>EDIT:</p>
  
  <p>The C/C++ function definition:</p>
  
  <pre><code>int WLGenLicenseFileKeyW(    
  wchar_t* pLicenseHash,     
  wchar_t* pUserName,     
  wchar_t* pOrganization,    
  wchar_t* pCustomData,     
  wchar_t* pMachineID,   
  int NumDays,    
  int NumExec,    
  SYSTEMTIME* pExpirationDate,     
  int CountryId,     
  int Runtime,     
  int GlobalTime,    
  char* pBufferOut    
  );
  </code></pre>
  
  <p>That is all the information that the documentation gives on the function.</p>