Parameter transmission mode:
Delphi has its own parameters, and the Windows API also has its own parameters, then what there is differences between them, how to be compatible, especially when writing a dynamic library?
(1) CDECL:
Usually the parameter transfer mode used by C / C , its transmission mode is from right to left, and after the call is completed, the parameter data on the stack will be cleared by the calling function itself.
(2) stdcall:
The parameter transmission mode is also from right to left, but after the call is called, the parameter data on the stack is cleared by the called function. All the output functions of Win32API use this parameter transmission method.
(3) Pascal:
It is the parameter transfer method used by Delphi1.0 and Win16API. Its delivery mode is left to right and the parameter data on the stack is cleared by the called function.
(4) FastCall:
It is the parameter delivery mode used by Delphi. In this way, the top three parameters are placed in the CPU Eax, EDX, ECX, and the remaining parameters will be taken out by left to right. Put it in the stack, and after the call is called, the parameter data on the stack is cleared by the called function.
Note: So when you reference the function in the C dynamic library, you should pay attention to the transmission method of the parameters, generally use stdcall. Also pay attention to the string type, C is passing the string, is the type of character pointer (char *), So you must use a PCHAR type in Delphi programs instead of a string type.