进程之间发送字符串 procedure PostStrToOther(H: HWND; OtherStr: string); var DS: TCopyDataStruct; begin ShowMessage('发送:' + OtherStr); Ds.cbData := Length(OtherStr) + 1; //或者是结构体长度 sizeof(结构体变量) GetMem(Ds.lpData, Ds.cbData); StrCopy(ds.lpData, PChar(OtherStr)); SendMessage(H, WM_COPYDATA, Application.Handle, Cardinal(@ds)); FreeMem(Ds.lpData); end; procedure TFrmOther.MyMessage(var t: TWMCopyData); //Message WM_COPYDATA; var tmpStr:String; begin //接受消息并显示。 tmpStr:=StrPas(t.CopyDataStruct^.lpData); Memo1.Lines.Add(tmpStr); end;=========发送文件大小,方法也差不多。