我在 C# 中有 2 个应用程序通过 Windows 消息 App1:向 App2 发送消息
string msg=UserName+","+UserAge;
byte[] sarr =System.Text.Encoding.Default.GetBytes(msg);//
int len = sarr.Length;
COPYDATASTRUCT cds;
cds.dwData = (IntPtr)100;
cds.lpData = msg;
cds.cbData = len + 1;
result = SendMessage(hWnd, WM_COPYDATA, wParam, ref cds);
App2:接收来自 App1 的消息
COPYDATASTRUCT sentPara = new COPYDATASTRUCT();
Type mytype = sentPara.GetType();
sentPara = (COPYDATASTRUCT)message.GetLParam(mytype);
string[] parameters = sentPara.lpData.Split(',');
问题: 用户名是俄语,当我在 App2 中收到它时,我得到问号“???????”,我认为这是字节数组编码中的问题,但我不知道如何解决