Home > Back-end >  Consult, Delphi writing ocx DLL with c problem
Consult, Delphi writing ocx DLL with c problem

Time:10-03

Java BS development has been doing, so don't know much about Delphi, consult everybody!
Project needs to be done in an interface, because to call DLL, so only use js calls ocx, ocx as an intermediary call interface DLL, the implemented before other interface, so the scheme is feasible,
This call DLL is API is likely (C), the way of the header file is as follows:
Typedef void (WINAPI * Callback) (char * MSG);//callback function type
Extern "C"
{
Void __stdcall SetClientCallback (Callback lpCallback);
Void __stdcall Request (const char * EntPara, char * RetPara, short * iRetValue);
}
The interface definition:
Void Request (char * EntPara [in], char * RetPara [out], Short * iRetValue [in, out])
Current static statement 1:
Procedure Dll_Request (var inPara, outPara: PChar; Var retPara: an array of short); Stdcall; External 'miclient. DLL' name 'Request;
The
Dll_Request (inPara outPara, retPara);
There seems to be a abnormal call

The static statement 2:
Procedure Dll_Request (var inPara outPara: an array of char; Var retPara: an array of short); Stdcall; External 'miclient. DLL' name 'Request;
The
Dll_Request (inPara outPara, retPara);
Call property does not return

What should consult calls to correct

CodePudding user response:

Short * iRetValue corresponding translation for iRetValue: PShortInt

CodePudding user response:

reference 1st floor Avan_Lau response:
Short * iRetValue corresponding translation for iRetValue: PShortInt


Oh thank you I try
The char * RetPara use PChar or an array of char some right?
Before an interface with an array of char * char call succeeded

CodePudding user response:

refer to the second floor xuexue1987 response:
Quote: refer to 1st floor Avan_Lau response:

Short * iRetValue corresponding translation for iRetValue: PShortInt


Oh thank you I try
The char * RetPara use PChar or an array of char some right?
Before an interface with an array of char * char call success

An array of char array name for the actual pointer type, if the size is ok, had better use pchar, getMem

CodePudding user response:

Request (const char * EntPara, char * RetPara, short * iRetValue);
Should be
Request (const EntPara: PAnsiChar; RetPara: PAnsiChar; IRetValue: PShortInt);

CodePudding user response:

If change an array of char, PChar, don't pass an array of char, this can't use the previous view, although different DLL you look he is char *, but internal implementation who knows he is how to write, usually see a char * PChar instead, there is no problem!

CodePudding user response:

Page callback ocx it confirm ok

CodePudding user response:

Delphi dynamic array in C can not corresponding type.
You still use Pansichar here.