View Code
1 //VC Unicode项目
2 var
3 wData: String;
4 h: HWND;
5 cds: TCopyDataStruct;
6 begin
7 wData:= '1234567890'+ Chr(0);
8 cds.dwData:= 0;
9 cds.cbData:= Length(wData);
10 cds.lpData:= PWideChar(wData);
11 SendMessage(h, WM_COPYDATA, 0, LongWord(@cds));
12 end
13
14 //非VC Unicode项目
15 var
16 wData: WideString;
17 h: HWND;
18 cds: TCopyDataStruct;
19 begin
20 wData:= '1234567890'+ Chr(0) + Chr(0);
21 cds.dwData:= 0;
22 cds.cbData:= Length(wData) * 2 + SizeOf(WChar) * 2;
23 cds.lpData:= PWideChar(wData);
24 SendMessage(h, WM_COPYDATA, 0, LongWord(@cds));
25 end
2 var
3 wData: String;
4 h: HWND;
5 cds: TCopyDataStruct;
6 begin
7 wData:= '1234567890'+ Chr(0);
8 cds.dwData:= 0;
9 cds.cbData:= Length(wData);
10 cds.lpData:= PWideChar(wData);
11 SendMessage(h, WM_COPYDATA, 0, LongWord(@cds));
12 end
13
14 //非VC Unicode项目
15 var
16 wData: WideString;
17 h: HWND;
18 cds: TCopyDataStruct;
19 begin
20 wData:= '1234567890'+ Chr(0) + Chr(0);
21 cds.dwData:= 0;
22 cds.cbData:= Length(wData) * 2 + SizeOf(WChar) * 2;
23 cds.lpData:= PWideChar(wData);
24 SendMessage(h, WM_COPYDATA, 0, LongWord(@cds));
25 end
VC接收消息代码:
BOOL CGVideoDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
MessageBox((LPCTSTR)(pCopyDataStruct->lpData));
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
MessageBox((LPCTSTR)(pCopyDataStruct->lpData));
return CDialog::OnCopyData(pWnd, pCopyDataStruct);
}