I am able to get a Structure populated as a result of a dll-function (as it seems looking into it using
x=buffer(MyData)
and then repr(str(buffer(x)))
)
But an error is raised if I try to access the elements of the Structure using .value
I have a VarDefs.h that requires a struct like this:
typedef struct
{
char Var1[8+1];
char Var2[11+1];
char Var3[3+1];
...
}TMyData
that should be passed to a function like this:
__declspec(dllexport) int AFunction(TOtherData *OtherData, TMyData *MyData);
In Python I am now able to declare the structure this way (thanks to Mr. Martelli: see here http://stackoverflow.com/questions/3488173/python-ctypes-dll-function-accepting-structures-crashes ):
class TMyData( Structure ):
_fields_ = [
("Var1" , type( create_string_buffer(9) ) ),
("Var2" , type( create_string_buffer(12)) ),
... `
I call the function this way:
result = Afunction( byref(OtherData) , byref(MyData ) )
As said, as I try to access MyData.Var1.value
I get an error (sorry, can't be more specific now!), but repr(str(x))
where x is a copy of buffer(MyData)
shows that there are data in it!
How should I do it instead? Thanks!