title: is there struct tagging conventions in python ctypes.Structure?
body: <p>I am porting visual c++ 6 application to python using ctypes.
  It uses same windows library dll. and I am only porting windows forms to python application.</p>
  
  <p>and I am stucked when I am sending cpp structure to dll in python.</p>
  
  <p>I have tried to find solution on the struct differeces. from cpp code, there is a struct tagging(tagTest) but there is no equivalent in python code. is there any solution for that?</p>
  
  <p>this is cpp that I want to port from.</p>
  
  <p>========================cpp part================================</p>
  
  <pre><code>BOOL CSMessage(HWND hWnd, const char* string1, const char* string2, const char* ltagTest, int structlen);
  
  typedef struct tagTest
  {
      char item1                     [  8];   char _item1;
      char item2                     [  1];   char _item2;
  } TcTest, *LPTest;  
  
  void Initiator()
  {
      TcTest  ctest   ={0};
      memset(&amp;ctest,0x20,sizeof TcTest);
      move(ctest.item1,"TESTSTRI");
      move(ctest.item2,"1");
  
      mhandler.CSMessage(GetSafeHwnd(),"String","Call",(char*)&amp;ctest,sizeof TcTest);
  }
  </code></pre>
  
  <p>=========================pythonpart============================</p>
  
  <pre><code>csMessageProto=ctypes.WINFUNCTYPE(BOOL, HWND, c_char_p, c_char_p, c_char_p, c_int)
  csMessageParams=((1,"hWnd",0),(1,"string1",0),(1,"string2",0),(1,"ltagTest",0),(1,"structlen",0))
  CSMessage=csMessageProto(("CSMessage",testDll), csMessageParams)
  
  class tagTest(ctypes.Structure):
      _fields_ = [
          ('item1', c_char*8),('_item1', c_char),
          ('item2', c_char*1),('_item2', c_char)
      ]
  PtagTest=ctypes.POINTER(tagTest)
  
  utestblock=tagTest()
  utestblock.item1=str("TESTSTRI")
  utestblock.item2=str(1)
  
  CSMessage(hwnd, "String", "Call", ctypes.byref(utestblock), ctypes.sizeof(utestblock));
  </code></pre>
  
  <hr>
  
  <p>revision history</p>
  
  <ol>
  <li>added declaration of dll function both cpp and python</li>
  <li>revised with @avl_sweden suggestions</li>
  </ol>
  
  <p>=====================result==============================</p>
  
  <p>after applying @avl_sweden's suggestion,
  After test, the error msg is this.</p>
  
  <pre><code>ctypes.ArgumentError: argument 4: &lt;type 'exceptions.TypeError'&gt;: wrong type
  </code></pre>
  
  <p>and for the type</p>
  
  <pre><code>print "Is Type : "+str(ctypes.byref(utestblock))
  
  Is Type : &lt;cparam 'P' (023e5968)&gt;
  </code></pre>
  
  <p>=========================================================</p>
  
  <p>so it's looks like types are different in def and instance.</p>
  
  <p>in first line in python code</p>
  
  <pre><code>1: csMessageProto=ctypes.WINFUNCTYPE(BOOL, HWND, c_char_p, c_char_p, c_char_p, c_int)
  </code></pre>
  
  <p>the fourth c_char_p is not matching </p>
  
  <pre><code>16: CSMessage(hwnd, "String", "Call", ctypes.byref(utestblock), ctypes.sizeof(utestblock));
  </code></pre>
  
  <p>to match the differences.</p>
  
  <p>I changed code to</p>
  
  <pre><code>1: csMessageProto=ctypes.WINFUNCTYPE(BOOL, HWND, c_char_p, PtagTest, c_char_p, c_int)
  </code></pre>
  
  <p>and code returns no error. but I cannot find if it is sent through. becuase there was no return from dll.</p>
  
  <p>do you think this is the right solution?</p>
  
  <p>=====================================================================================</p>
  
  <p>i have been tested and it seems it is right solution.</p>
  
  <p>Thank you again.</p>