这样处理发送消息与接收消息有什么问题吗?
procedure SendData(AFileString:WideString); 发送AFileString
var
ds:TCopyDataStruct;
hd:THandle;
begin
hd:=FindWindow(...);
if hd>0 then
begin
ds.cbData:=Length(AfileString)+1;
GetMem(ds.lpData,ds.cbData);
StrPCopy(ds.lpData,AFileString);
SendMessage(hd,WM_CopyData,0,cardinal(@ds));
FreeMem(ds.lpdata);
end
else
......
end;
接收消息的处理
procedure ReceiveMessage(var Msg:TWMCopyData);message WM_CopyData;
begin
showmessage(strpas(Msg.copydatastruct.cbdata));
end;
问题是:为什么AFileString都为字符时收到的字符串是正确的,但AFileString含有中文字时,接收的和发送的字符串就不一样呢?哪位高手知道原因,拜托了,谢谢.