Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从dll函数返回字符串数组_C++_Delphi_Delphi 7 - Fatal编程技术网

C++ 从dll函数返回字符串数组

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

如何从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_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;