3
我的Delphi应用程序正在从一个C++ DLL调用一个函数,它应该像这样返回字符串。如何使用字符串参数在Delphi中调用C++ DLL?
C++ DLL
__declspec(dllexport) void sample(char* str1, char* str2)
{
strcpy(str1, "123");
strcpy(str2, "abc");
}
德尔福
procedure sample(Str1, Str2: pchar); cdecl; external 'cpp.dll';
var
buf1 : Pchar;
buf2 : Pchar;
begin
sample(@buf1, @buf2);
//display buf1 and buf2
//ShowMessage(buf1); //it display random ascii characters
end;
什么是做这种正确的方法是什么?
这个问题不是很清楚吗? –