I receive this error when I try to call this function written in Delphi. But another code works fine. Maybe I'm not declaring the args ans result types? I am using 32Bit python 3.7). Related code snippets:
Delphi:
Test(deposit, MarginCall: double; CallBack: TProgrCallBackProc); stdcall;
Python:
self.FTCore = ctypes.WinDLL(self.FTCore_library_path)
self.FTCore.Test.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double)]
self.FTCore.Test.restype = ctypes.POINTER(ctypes.c_char)
deposit = ctypes.c_double(100)
callback = ctypes.c_double(1)
self.FTCore.Test(deposit, callback)
Error:
violation reading 0x00000004
Three errors that I can see:
argtypes. You will need to define the third argument, TProgrCallBackProc defined somewhere in the Delphi code.argtypes definition. They should be defined as plain ctypes.c_double.restype contradicts that. You need to set restype to None.User contributions licensed under CC BY-SA 3.0