delphi 简单的Bug报告类
2014-04-17 17:11
274 查看
unit uBugReport; interface uses Windows, SysUtils, SyncObjs; procedure ReportBug(pszBugStr: PChar); stdcall; implementation var LogFileLock: TCriticalSection; function GetAppRoot: string; var path: string; begin SetLength(path, MAX_PATH); SetLength(path, GetModuleFileName(HInstance, PChar(path), MAX_PATH)); path := ExtractFilePath(path); Result := StringReplace(path, 'bin\', '', [rfIgnoreCase]); end; procedure ReportBug(pszBugStr: PChar); var strPath: string; strFileName: string; F: Text; S: string; dtNow: TDateTime; begin try OutputDebugString(pszBugStr); LogFileLock.Enter(); try dtNow := Now(); strPath := GetAppRoot() + 'Logs\'; strFileName := strPath + FormatDateTime('YYYY-MM-DD', dtNow) + '.log'; if not DirectoryExists(strPath) then ForceDirectories(strPath); AssignFile(F, strFileName); try if FileExists(strFileName) then Append(F) else Rewrite(F); S := FormatDateTime('YYYY-MM-DD HH:MM:SS', dtNow) + ' ' + StrPas(pszBugStr); Writeln(F, S); finally CloseFile(F); end; finally LogFileLock.Leave(); end; except end; end; initialization IsMultiThread := True; LogFileLock := TCriticalSection.Create(); finalization FreeAndNil(LogFileLock); end.
相关文章推荐
- Delphi下使用指针的简单总结
- 简单的Delphi三层程序开发
- [转]DELPHI中完成端口(IOCP)的简单分析
- Delphi-IOCP学习笔记<四>===小结<IOCP的简单例子>
- xDom-一个简单的Delphi框架-介绍及下载
- delphi多线程程序示例(与.net一样简单)
- 用DELPHI的RTTI实现数据集的简单对象化
- Delphi越来越多自动释放的类型,到底是简单还是复杂了?
- 使用Delphi,SDK编写Windows简单程序
- delphi来写你的第一个dll文件,非常简单!
- Delphi Ini 操作简单例子
- DELPHI中完成端口(IOCP)的简单分析(4)
- 推荐一款好用的bug管理系统,topbug.cc 一款简单易用的bug在线管理工具,而且免费。
- POJ 2856 Y2K Accounting Bug【简单暴力】
- 一个简单的MDI示范程序(Delphi)
- 保存delphiBBS.com上贴子的简单方法.
- Delphi组件开发教程指南(2)简单扩充TEdit -转摘
- Create a simple Delphi Expert(创建一个简单的Delphi专家)
- DELPHI中完成端口(IOCP)的简单分析
- 如何用Delphiz做简单的Gecko浏览器