VC如何调用DELPHI编写返回为字符串的DLL
这个VC调用Delphi返回值为整型的DLL示例
int(__stdcall * ReadPrintCountR)(int pa);
HINSTANCE hDll3 = LoadLibrary("Print.DLL");
ReadPrintCountR = (int(__stdcall *)(int pa))(GetProcAddress(hDll3, "ReadPrintCount"));
int p = ReadPrintCountR(0);
FreeLibrary(hDll3);
----------------------------------------------------------------------------------------------------
那么VC调用返回值为字符的调用应该怎么写?要求调用后的返回值用edit文本框显示
delphi里的编写的返回字符的原型函数的DLL是这样写的
function GetValue(pchar1:pchar):pchar;stdcall;
implementation
{$R *.dfm}
function GetValue(pchar1:Pchar):PChar;
var str:string;
begin
frmPrint:=TfrmPrint.Create(Application);
str:='这是delphi返回的'+string(pchar1);
Result:=pchar(Str);
frmPrint.Free;
end;
-------------------------------------------------------------------------------------------------------------------
delphi调用这个DLL已可以,delphi调用示例如下,请问用VC调用实现如下功能怎么调用?
function GetValue(Phar1:Pchar):PChar;stdcall;External 'Print.dll';
procedure TForm1.btn1Click(Sender: TObject);
var str1,str2:string;
begin
str2:='123';
str1:= string( GetValue(PChar(str2)) );
edt1.Text:=str1;
ShowMessage(str1);
end;