可以用PostThreadMessage,例如:
//发送线程
//接受线程
procedure TThread2.Execute;
var
msg:TMsg;
sMes:String;
pMes:^String;
iTemp:Integer;
begin
//消息循环
while GetMessage(msg,0,0,0) do
begin
Case msg.message of
WM_StartRecording:
begin
//传过来的是String;
pMes:=msg.wParam;
sMes:=pMes^;
Dispose(pMes);
WM_OriginalData:
begin
//传过来的是整数
iTemp:=msg.WParam;
end;
else begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end;
end;
end;(转注:这是发送string和integer的,还可以发送stringlist,方法是:发送方:a:TStrings;a := TStringList.Create;SendMessage(Formb.Handle, WM_YOURMESSAGE, 0, LongInt(a));接收方:b:TStrings;b := TStringList.Create;b.Assign(TStrings(Msg.WParam));TStrings(Msg.WParam).Free;剩下就是你自己要怎么处理b的问题了。)
转载于:https://blog.51cto.com/zsqztg/151285