本节是VC发消息,DELPHI端接收,VC字符集分为“Unicode”和”多字节“。
VC---->Unicode发送端代码:
CString strSend = "要发送的信息";
strSend.ReleaseBuffer();
CWnd *pWnd = CWnd::FindWindow(NULL, "Delphi接收端");
if (pWnd)
{
COPYDATASTRUCT cds;
cds.dwData = 0;
cds.cbData = strSend .GetLength() * sizeof(WCHAR) + sizeof(WCHAR);
cds.lpData = (void*)strSend.GetBuffer(cds.cbData);
pWnd->SendMessage(WM_COPYDATA, 0, (LPARAM)&cds);
}
DELPHI--->Unicode接收代码:
cStr: WideString;
cStr:= PWideChar(t.CopyDataStruct^.lpData);