procedure LogInfo(msg: string);
// 功能: 服务端日志
var
p: PChar;
begin
try
GetMem(p, (Length(msg) + 1) * sizeof(char));
Move(msg[1], p^, (Length(msg) + 1) * sizeof(char));
PostMessage(Application.MainForm.Handle, WM_LOG, integer(p), 0);
except
Exit;
end;
end;
procedure Tf_MainForm.Log(var msg: TMessage);
var
p: PChar;
begin
try
p := PChar(msg.WParam);
if Assigned(p) then
begin
AddMemo(p);
FreeMem(p);
end;
except
on E: Exception do
begin
LogInfo('Tf_MainForm.Log---' + E.Message);
exit;
end;
end;
end;