SendMessage 只发送 VC++ 的第一个消息包,你能帮忙吗?只收到第一份章程。
实际上这是我的完整发件人应用程序代码(VC++)
// notification->FileName is UCHAR[255]
HWND app = FindWindow(NULL,TEXT("Message Receiver"));
COPYDATASTRUCT cds;
cds.dwData = 0; // can be anything
cds.cbData = sizeof(notification->FileName) - sizeof(UCHAR);
cds.lpData = (void*)notification->FileName;
SendMessageA(app, WM_COPYDATA, (WPARAM)app, (LPARAM)&cds);
我的接收者代码(Delphi)
procedure TfrmReceiver.WMCopyData(var Msg: TWMCopyData);
var
sText: array[0..255] of Char;
s: string;
ms: TMemoryStream;
begin
case Msg.CopyDataStruct.dwData of
0: { Receive Text, Text empfangen}
begin
StrLCopy(sText, Msg.CopyDataStruct.lpData,Min(Length(sText), Msg.CopyDataStruct.cbData));
label1.Caption := sText;
end;
1: { Receive Image, Bild empfangen}
{
begin
ms := TMemoryStream.Create;
try
with Msg.CopyDataStruct^ do
ms.Write(lpdata^, cbdata);
ms.Position := 0;
image1.Picture.Bitmap.LoadFromStream(ms);
finally
ms.Free;
end;
end; }
end;
end;