I can get the structure populated as a result of the DLL function (what it looks like in it using x=buffer(MyData) and then repr(str(buffer(x))) .
But an error occurs if I try to access the elements of the Structure using .value .
I have VarDefs.h which requires a structure like this:
typedef struct { char Var1[8+1]; char Var2[11+1]; char Var3[3+1]; ... }TMyData
which should be passed to such a function:
__declspec(dllexport) int AFunction(TOtherData *OtherData, TMyData *MyData);
In Python, I can now declare a structure this way (thanks to Mr. Martelli: see here Python ctypes - dll function for accepting structural failures ):
class TMyData( Structure ): _fields_ = [ ("Var1" , type( create_string_buffer(9) ) ), ("Var2" , type( create_string_buffer(12)) ), ...
I call the function as follows: result = Afunction( byref(OtherData) , byref(MyData ) )
As I said, when I try to access MyData.Var1.value , I get an error message (sorry, now could not be more specific!), But repr(str(x)) , where x is a copy of buffer(MyData) shows that in it!
How can I do it? Thanks!
source share