输出时遇到乱码,有人能贴出正确的代码吗?
我的代码是这样写的
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);
}
}
我的代码是这样写的
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);
}
}
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam); 我来拿分~
嘿嘿!
终结标志,接收程序能很好地接收到完整文字。
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);
}
}