Home Declare delphi structure with ctypes
Reply: 0

Declare delphi structure with ctypes

user825
1#
user825 Published in May 21, 2018, 9:16 am

I have delphi dll named lib.so It have structure:

TRec1 = packed record
    Version:UInt32
end;
Prec=^TRec1

function get_version(ARec: PRec): integer;
begin
  Result := 1;
  FillChar(ARec, SizeOf(TRec1), 0);
  ARec^.Version := 2;
  Result := 0;
end;

Dll have function get_version, that take pointer on this structure and return change structure.

Python code:

from ctypes import *
class TRec1(Structure):

_pack_ = 1
_fields_=[
('Version',c_uint32) 
]

PRec1=TRec1()
a=cdll.LoadLibrary('/home/Test_In_memmory_perfomance/lib.so')
print a.get_version(PRec1)

Function return Exception,that structure dont declare. When I try call get_version('string') it return OK, but i dont have callback.

Is my structure declare correctly?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.416037 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO