Void OperateDisk (LPSTR strInputInfo, LPSTR * strOutputInfo)
I generate the Delphi interface
Procedure OpenXX (strInputInfo: pchar; Var strOutputInfo: pPAnsiChar); Cdecl; External 'OPEN_DLL. DLL';
Call the test code:
Var
S1: pchar;
S2: pPAnsiChar;
The begin
S1:='12345678'.
OpenXX (s1, s2);
StrValue:=strpas (@ s2);
ShowMessage (' length: '+ IntToStr (StrLen (@ s2)));
Showmessage (StrValue);
The end;
After the compilation is normal, but call execution will address errors,
Please expert advice, thank you!
CodePudding user response:
LPSTR * corresponding PPAnsiChar is right, also can be PLPSTR, Windows unit statement.Void OperateDisk (LPSTR strInputInfo, LPSTR * strOutputInfo); Should be translated into
The following two kinds of any kind will do.
Procedure OperateDisk (strInputInfo: LPSTR. Var strOutputInfo: LPSTR); Cdecl; External 'OPEN_DLL. DLL';
Procedure OperateDisk (strInputInfo: LPSTR. StrOutputInfo: PLPSTR); Cdecl; External 'OPEN_DLL. DLL';
Another is cdecl or stdcall agreed the original poster to reconfirm
Two types of statement calling difference is:
Procedure OperateDisk (strInputInfo: LPSTR. Var strOutputInfo: LPSTR); Cdecl; External 'OPEN_DLL. DLL';
.
Var
S1: LPSTR.
S2: LPSTR.
The begin
S1:='12345678'.
OperateDisk (s1, s2);
Showmessage (StrPas (s2));
The end;
Procedure OperateDisk (strInputInfo: LPSTR. StrOutputInfo: PLPSTR); Cdecl; External 'OPEN_DLL. DLL';
.
Var
S1: LPSTR.
S2: LPSTR.
The begin
S1:='12345678'.
OperateDisk (s1, @ s2);
Showmessage (StrPas (s2));
The end;
Or add a phrase "
Procedure OperateDisk (strInputInfo: LPSTR. Var strOutputInfo: LPSTR); Cdecl; The phrase "; External 'OPEN_DLL. DLL';
Procedure OperateDisk (strInputInfo: LPSTR. StrOutputInfo: PLPSTR); Cdecl; The phrase "; External 'OPEN_DLL. DLL';
This can be in two ways, will have the same function call
CodePudding user response:
@ wr960204Thank you for your advice, but according to your method, after the execution, the return value, but all of the code after the execution is to address an exception!
Are there any other reasons? Is a pointer not stated length or destruction caused by the
Can add my QQ: 46513544, help! Thank you very much!
According to the
Stdcall seems to also not line!
CodePudding user response:
Use PChar seeCodePudding user response: