输出时遇到乱码,有人能贴出正确的代码吗?
我的代码是这样写的
IntPtr ipFouceWindow;
char[] cCont = sCont.ToCharArray();
//区分普通窗口和命令行窗口
if (ipFouceWindow != (IntPtr)0)
{
    for (int j = 0; j < sCont.Length; j++)
    {
        Win32API.PostMessage(ipFouceWindow, (uint)Win32API.WindowsMessages.WM_CHAR, (uint)(cCont[j]), 0);
    }
}

解决方案 »

  1.   

    [DllImport("user32.dll", CharSet = CharSet.Unicode)]//这里使用unicode 获知anis看看 
            public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam); 我来拿分~
    嘿嘿!
      

  2.   

    我建立一个Message实例,直接给其WParam属性赋值,最后加一个表示发送完毕的
    终结标志,接收程序能很好地接收到完整文字。
      

  3.   

    IntPtr ipFouceWindow; 
    byte[] bzSend = System.Text.Encoding.Ascii.GetBytes(sCont); 
    //区分普通窗口和命令行窗口 
    if (ipFouceWindow != (IntPtr)0) 

        for (int j = 0; j  < bzSend.Length; j++) 
        { 
            Win32API.PostMessage(ipFouceWindow, (uint)Win32API.WindowsMessages.WM_CHAR, (uint)(bzSend[j]), 0); 
        } 
    }