title: Python passing user-defined class by reference to DLLs
body: <p>I am currently working on a project that requires to access functions in DLLs, and I found ctypes to handle the function call for me. However, I encounter some difficulties when some functions ask to pass parameters by reference. I've tried the ctypes.by_ref() but it doesn't work because the object is a user-defined class.</p>
  
  <p>And then I gave ctypes.pointer() a try and it spits out the error message: "<em>type</em> must have storage info". I guess that means it only takes ctypes data types?</p>
  
  <p>My code:</p>
  
  <pre><code>from ctypes import *
  class myclass():
      a= None # requiring c_int32
      b= None # requiring c_int32
  myci= myclass()
  myci.a= c_int32(255)
  myci.b= c_int32(0)
  mycip= pointer(myci)  # let's say it's Line 8 here
  loadso= cdll.LoadLibrary(mydll)
  Result= loadso.thefunction (mycip) # int thefunction(ref myclass)
  </code></pre>
  
  <p>And the terminal output:</p>
  
  <pre><code>Line 8: TypeError: _type_ must have storage info
  </code></pre>
  
  <p>I would like to know 1) what does that error message mean? and 2) the way to work around and pass a user-defined class by reference to an external DLL.</p>
  
  <p>Thank you in advance for your time.</p>