Call the PTKAlarmSDK. DLL
# ifdef PTKALARMLIB_EXPORTS
# define PTKALARMLIB_API extern "C" __declspec (dllexport)
# the else
# define PTKALARMLIB_API extern "C" __declspec (dllimport)
# endif
Declare the callback function
Typedef struct
{
Void (* PTK_UserCommandSuccessful) (const void * sender, uint receid, uchar hostid, uchar terid, uchar commandcode);
Void (* PTK_UserCommandDelete) (const void * sender, uint receid, uchar hostid, uchar terid, uchar commandcode);
Void (* PTK_Alarm_Information) (const void * sender, uint receid, uchar hostid, uchar terid, uchar areaid);
Void (* PTK_Alarm_KpdDisplay) (const void * sender, uint receid, uchar hostid, uchar * Dis1, uchar * Dis2);
} SPTK_callbackFun;
Define an interface DLL function
PTKALARMLIB_API void * Init_PTKAlarmlib (const void * sender, SPTK_callbackFun * CallBack);
Finally how to call this interface function
CodePudding user response:
Haha, to be honest, I'm sorry, I am currently Delphi are amateurs. I don't understand, I'll contact points, so that I can follow-up questions, hehe!
CodePudding user response:
Delphi DLL function call way:
The function Sub_Add (const id: integer) : integer; Stdcall; External 'login. DLL';
Declare a function, the parameter types with the same DLL, stdcall after plus external, followed by a DLL file name, you can specify locations such as "c: \ login. DLL"
CodePudding user response:
refer to the second floor qecloud response: Delphi DLL function call way: The function Sub_Add (const id: integer) : integer; Stdcall; External 'login. DLL'; Declare a function, the parameter types with the same DLL, stdcall after plus external, followed by a DLL file name, you can specify a location such as "c: \ login. DLL" Don't mislead people, if the original poster said DLL is C way and posted by the statement and as a building is shown in words # ifdef PTKALARMLIB_EXPORTS # define PTKALARMLIB_API extern "C" __declspec (dllexport) # the else # define PTKALARMLIB_API extern "C" __declspec (dllimport) # endif The default calling convention is __cdecl C, I can't see your DLL export above shows have stdcall, or def, and the structure of the you Typedef struct { Void (* PTK_UserCommandSuccessful) (const void * sender, uint receid, uchar hostid, uchar terid, uchar commandcode); Void (* PTK_UserCommandDelete) (const void * sender, uint receid, uchar hostid, uchar terid, uchar commandcode); Void (* PTK_Alarm_Information) (const void * sender, uint receid, uchar hostid, uchar terid, uchar areaid); Void (* PTK_Alarm_KpdDisplay) (const void * sender, uint receid, uchar hostid, uchar * Dis1, uchar * Dis2); } SPTK_callbackFun; Four function pointer also should have corresponding calling convention's instructions, this you have to ask the DLL author in detail,