服务端日志记录

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;

posted @ 2012-03-05 22:54  delphi中间件  阅读(909)  评论(0编辑  收藏  举报