VC Delphi WM_COPYDATA 消息

Delphi端发消息,VC接收消息参见: VC Delphi WM_COPYDATA 消息
本节是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);


原文地址:https://www.cnblogs.com/whisht/p/4098858.html