string s = textBox1.Text;
byte[] b = UnicodeEncoding.Default.GetBytes(s);
char[] c = UnicodeEncoding.Default.GetChars(b, 0, b.Length);
string s1 = textBox2.Text;
byte[] b1 = UnicodeEncoding.Default.GetBytes(s);
char[] c1 = UnicodeEncoding.Default.GetChars(b, 0, b.Length);
textBox3.Text = cCdll.strA(C,C1);

解决方案 »

  1.   

                [DllImport("test.dll", EntryPoint = "strA", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
                public static extern IntPtr strA(IntPtr a, IntPtr b); 
    改这样吧,C#的char貌似不是单字节的
    IntPtr a=Marshal.StringToBSTR(textBox1.Text);
    IntPtr b=Marshal.StringToBSTR(textBox2.Text);
    IntPtr d=strA(a,b);
    TextBox3.Text=Marshal.PtrToStringAuto(d);
    试试看
      

  2.   

    textBox3.Text = cCdll.strA(textBox1.Text.ToCharArray(),textBox2.Text.ToCharArray()).ToString();