c++写的DLL里面有这样一个函数: 
int IBSetup(long seed,int iPBit,int iQBit,char *sCommonFileName,char *sMasterFileName, *sSecretKey[2]);其中的char *sCommonFileName,char *sMasterFileName, *sSecretKey[2]都是指针传参的。 
我希望传递的参数在这个函数里面得到修改。现在的问题是,我在c#调用的时候该怎么用c#的指针来传递这些参数呢?
(因为这些指针参数都是返回值,所以不能通过修改返回值的类型解决。)
(已经更改了项目安全属性,允许不安全代码了) 为了大家方便分析问题,我提供两个c++里面时可以正确传递的两个参数: 
C++: 
char *sCommonFileName="d:\\common.ibe"; 
char *sMasterFileName="d:\\master.ibe"; 

解决方案 »

  1.   

    C# 中用 StringBuilder http://topic.csdn.net/u/20090418/23/ffd7ca16-e581-4c3c-acfd-282236096e4c.html
      

  2.   

    public unsafe static extern void getValue(byte[] c1); 
    然后new 一个byte[]传过去。
      

  3.   

    int IBSetup(long seed,int iPBit,int iQBit,char *sCommonFileName,char *sMasterFileName, *sSecretKey[2]);
    char *用C#里面的byte[]就好了
      

  4.   

    按照大家的方法,其他都解决了。现在是*sSecretKey[2]这个数组的指针该怎么传递呢?
      

  5.   

    需要获得这个二维数组在DLL中被修改。我用stringbuilder的二维数组试了,结果没有被修改……
      

  6.   

    试试用IntPtr传递 *sSecretKey[2]
      

  7.   

    我也遇到这个问题了,急啊,
    C++ 的函数原型是样的
    extern "C" int PASCAL EXPORT StopShowSendData(char * DataArry[3]);  传StringBuilder进去后没反应,那DLL不是我写的,不知道里面都干了些什么