听说有个工具能将普通DLL转变为.NET框架下DLL

解决方案 »

  1.   

    Gpg函数调用成功,现在就是Tpg函数调用失败了!大家帮帮忙啊!!
      

  2.   

    C#认为指针是不安全的,如果要使用碧血unsafe定义您的引用
      

  3.   

    ms-help://MS.VSCC/MS.MSDNVS.2052/csref/html/vclrfUnsafe.htm
      

  4.   

    我不会c++,亲参照
    http://expert.csdn.net/Expert/topic/1693/1693823.xml?temp=.4975702
      

  5.   

    把此dll通过组件服务工具或者soap toolkit转换成web service试试
      

  6.   

    extern __declspec(dllimport) int __stdcall Tpg(char*OutStr,const char*InStr,int x);
    此函数的OutStr参数要返回一个又处理过的串,用STRING可能不行,我正打算用StringBuilder类型再试试,请大家继续关注!谢谢!
      

  7.   

    问题已解决,最终调用形式如下:
    DLL中函数声明如下:
    extern __declspec(dllimport) int __stdcall Tpg(char*OutStr,const char*InStr,int x);extern __declspec(dllimport) int __stdcall Gpg(char*buf,int max);
    /* buf 为字串指针 */
    /* max 为buf字串长度 */我在C#中声明如下:
    [DllImport("go.dll"]
    public extern static int Tpg([ MarshalAs (UnmanagedType.LPStr)]stringBuilder OutStr,[ MarshalAs (UnmanagedType.LPStr)]string InStr,int x);

    [DllImport("go.dll")]
    public extern static int Gpg([ MarshalAs (UnmanagedType.LPStr)]stringBuilder buf,int max);调用成功,返回值正常!谢谢楼上的各位,来者有分!:)