本帖最后由 bdmh 于 2014-11-20 13:14:24 编辑

解决方案 »

  1.   

    试试设置DllImport的CallingConvention属性为CallingConvention.Cdecl
      

  2.   


    改成这样吗? 
            [DllImport("SLKKB.dll", EntryPoint = "ReadPwd", SetLastError = true,
                 CharSet = CharSet.Auto, ExactSpelling = false,
                 CallingConvention = CallingConvention.Cdecl)]
            public static extern StringBuilder ReadPwd(int cmd, int overtime);还是不行,报:vshost32.exe 已停止工作
      

  3.   

    其它几个CallingConvention也试一试。
      

  4.   

    然后调用PtrToStringAuto转成stringIntPtr ptr = foo();
    string str = Marshal.PtrToStringAuto(ptr);
      

  5.   

    可以确定是 返回值  char*  这里转错了,但是还是不知的怎么改
      

  6.   

    可以确定是 返回值  char*  这里转错了,但是还是不知的怎么改 
      

  7.   

    char * 的返回值 用 String 就够了,不要用 StringBuilder