C++ 从dll函数返回字符串数组
如何从C++ DLL返回字符串数组,然后函数将由Delphi应用调用。 我试过: C++动态链接库C++ 从dll函数返回字符串数组,c++,delphi,delphi-7,C++,Delphi,Delphi 7,如何从C++ DLL返回字符串数组,然后函数将由Delphi应用调用。 我试过: C++动态链接库 #include <windows.h> #include <vector> #include <string> using namespace std; extern "C" { __declspec( dllexport ) void arrayStr(vector<string> s) { s.push_b
#include <windows.h>
#include <vector>
#include <string>
using namespace std;
extern "C"
{
__declspec( dllexport ) void arrayStr(vector<string> s)
{
s.push_back("111");
s.push_back("222");
s.push_back("333");
}
}
< > >代码> TSTRIGLISTABS/COD>(Delphi)与C++ STL容器不兼容。p> 您应该执行以下操作: C/C++端:
void __stdcall Func(char **strings, int count);
德尔福方面:
type PPAnsiChar = ^PAnsiChar;
procedure Func(ArrayOfStrings: PPAnsiChar; CountOfArray: Integer); stdcall;
Delphi中的动态数组与char**不兼容,最好添加长度参数和指针或固定大小array@Andrew当前位置如果我是你,我会调整我的答案。需要进行更改否,那不行。继续努力。或者最好放弃,删除这个,让用户在dupe上阅读优秀的答案
type PPAnsiChar = ^PAnsiChar;
procedure Func(ArrayOfStrings: PPAnsiChar; CountOfArray: Integer); stdcall;