dll指针参数C#中如何解决
在调用C语言写的dll时参数是char*data,并且是传出的
我试了好写方法都不行.
请高手们帮帮忙

解决方案 »

  1.   

    using System.Runtime.InteropServices; [DllImport("user32.dll",EntryPoint="MessageBox",CharSet=CharSet.Auto)]
    public static extern int Msg(
    System.IntPtr hwnd,
    [MarshalAs(UnmanagedType.LPTStr)]
    string text,
    [MarshalAs(UnmanagedType.LPTStr)]
    string caption,
    int utype
    );
      

  2.   

    调用时和原型的参数前加 ref
      

  3.   

    我的dll中的函数是:
    int Read_Card(char* data);
    功能:
    从IC卡中读取数据并写在data所指向的内存
      

  4.   

    diandian82(点点):
    ref int 
    和我的问题有何关系?请说具体点
      

  5.   

    Have a try!
    char*:
    [Out]StringBuider 
      

  6.   

    前两天我也遇到了同样的问题
    http://community.csdn.net/Expert/topic/4909/4909159.xml?temp=.7286646
    这是我那篇帖子,你可以参考一下
    关键是StringBuilder这个类
      

  7.   

    [DllImport XXX]
    public static void funcation(ref StringBuilder data)