BOOLEAN Tuc_EnumTouchScreen (
OUT PCHAR * paths,
The OUT INT & amp; Count
);
Paths
[out] device path array,
Handle
[out] equipment number,
========================
C + + call example:
INT deviceCount=0;
PUCHAR devicePaths [64]={0};
for (int i=0; i<64; I++)
{
DevicePaths [I]=new char [256].
ZeroMemory (devicePaths [I], 256);
}
Tuc_EnumTouchScreen (devicePaths deviceCount);
In DELPHI, should how to declare?
I now declare:
The function Tuc_EnumTouchScreen (out paths: PChar; Out Handle: Integer) : Boolean; Stdcall; External 'TucLib. DLL' name 'Tuc_EnumTouchScreen';
Call is like this:
Procedure TForm1. Button1Click (Sender: TObject);
Var
I, the count: Integer;
Paths: array [0.. 63] PChar,
The begin
For I:=0 to 63 do
The begin
Paths: [I]=StrAlloc (256);
end;
Tuc_EnumTouchScreen (paths [0], count);
end;
Run prompt, input point can't locate the DLL program, excuse me, how should the declaration and calls,
CodePudding user response:
Above the D7 versionVar
I, the count: Integer;
Paths: array [0.. 63] of PAnsiChar;
The function Tuc_EnumTouchScreen (out paths: PChar; Out Handle: Integer) : Boolean; Stdcall; External 'TucLib. DLL' name 'Tuc_EnumTouchScreen';
->
The function Tuc_EnumTouchScreen (paths: PPAnsiChar; Handle: Integer) : Boolean; Stdcall; External 'TucLib. DLL' name 'Tuc_EnumTouchScreen';
The
Tuc_EnumTouchScreen (@ paths, Count);
If the paths is a dynamic array:
Paths: an array of PAnsiChar;
SetLength (paths, 64);
The
Tuc_EnumTouchScreen (paths, Count);
Parameter OUT are PCHAR * paths PPAnsiChar
Don't have to OUT the modifier
CodePudding user response:
1, from the point of C function declarations, and no __stdcall, __attribute__ ((stdcall)) this kind of modification, so you can't assume is stdcall calling convention,2, the OUT INT & amp; Count the reference parameters, i.e., the variable parameter in Pascal, should be translated as var count: integer
3, cannot use the dynamic array as paths parameters, Delphi compiler might be implied into a high dynamic array parameters bound parameters, lead to the count parameter to obtain is not correct,