The function aaa (CardCode: PAnsiChar; Var RtnStr: PAnsiChar) : Integer; Stdcall;
Var
Rtn: AnsiString;
The begin
ShowMessage (String (CardCode));//display normal
Rtn:='001 test | 1 | | | | 0' 200.03;
ShowMessage (String (Rtn));//normal shows 001 test | 1 | | | | 0 200.03
RtnStr:=PAnsiChar (Rtn);
ShowMessage (PChar (RtnStr));//not display properly
Result:=0;
end;
Pb9 calling code
String ls_ybkh ls_trn,
Int I
Ls_ybkh=space (128)
Ls_trn=space (256)
Ls_ybkh="001"
I=GetPersonInfo (ls_ybkh ls_trn)
MessageBox (' a ', '|' ls_ybkh + + ls_trn + '|' + string (I))
In a dynamic library will not be able to show to the returned string
In the pb is garbled
Don't use Delphi for a long time, don't know how to fixed, ask everybody to help, not enough, place another to open!!!!!!
CodePudding user response:
RtnStr:=PAnsiChar (Rtn);ShowMessage (PChar (RtnStr));//not display properly
You know not display properly, you don't know: ShowMessage (PAnsiChar (RtnStr)); ?????
CodePudding user response:
In pb display is garbled!CodePudding user response:
Pb is the string inside ansistring or unicodestring to be clear,CodePudding user response:
The string in the pb don't know what ahCodePudding user response:
According to try to know both ways,In addition, your pb GetPersonInfo (ls_ybkh ls_trn) function prototype declaration is what, and the function in the DLL aaa (CardCode: PAnsiChar; Var RtnStr: PAnsiChar) : Integer; Stdcall; Can on, especially the parameter passing way,
CodePudding user response:
StrPCopyCodePudding user response:
Pansichar and string can't direct transformation, using StrPCopy