Changeset 100 for ExceptionLogger/UExceptionLogger.pas
- Timestamp:
- Dec 21, 2010, 9:27:01 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ExceptionLogger/UExceptionLogger.pas
r40 r100 6 6 7 7 uses 8 {$ifdef windows}Windows,{$endif} 8 9 Classes, SysUtils, UStackTrace, CustomLineInfo, Forms; 9 10 … … 16 17 FMaxCallStackDepth: Integer; 17 18 FLogFileName: string; 19 function GetAppVersion: string; 18 20 procedure MakeReport; 19 21 procedure SetMaxCallStackDepth(const AValue: Integer); … … 49 51 SProcessID = 'Process ID'; 50 52 SThreadID = 'Thread ID'; 53 SVersion = 'Version'; 51 54 52 55 procedure Register; … … 81 84 Add(SMessage + ': ' + LastException.Message); 82 85 Add(SApplication + ': ' + Application.Title); 86 Add(SVersion + ': ' + GetAppVersion); 83 87 Add(STime + ': ' + DateTimeToStr(Now)); 84 88 Add(SProcessID + ': ' + IntToStr(GetProcessID)); … … 119 123 with TStackFrameInfo(StackTrace[I]) do begin 120 124 Line := IntToStr(Index) + ': ' + IntToHex(Address, 8) + ' in ' + FunctionName + ' ' + 121 Source + '(' + IntToStr(LineNumber) + ')' + #13#10;125 Source + '(' + IntToStr(LineNumber) + ')' + LineEnding; 122 126 if Length(Line) > 0 then 123 127 Write(Line[1], Length(Line)); 124 128 end; 125 Line := #13#10;129 Line := LineEnding; 126 130 Write(Line[1], Length(Line)); 127 131 finally … … 181 185 end; 182 186 187 function TExceptionLogger.GetAppVersion: string; 188 var 189 Size, Size2: DWord; 190 Pt, Pt2: Pointer; 191 begin 192 {$ifdef windows} 193 Size := GetFileVersionInfoSize(PChar(ParamStr(0)), Size2); 194 if Size > 0 then 195 begin 196 GetMem(Pt, Size); 197 try 198 GetFileVersionInfo(PChar (ParamStr(0)), 0, Size, Pt); 199 VerQueryValue(Pt, '\', Pt2, Size2); 200 with TVSFixedFileInfo(Pt2^) do 201 begin 202 Result := IntToStr(HiWord(dwFileVersionMS)) + '.' + 203 IntToStr(LoWord(dwFileVersionMS)) + '.' + 204 IntToStr(HiWord(dwFileVersionLS)) + '.' + 205 IntToStr(LoWord(dwFileVersionLS)); 206 end; 207 finally 208 FreeMem(Pt); 209 end; 210 end; 211 {$else} 212 Result := ''; 213 {$endif} 214 end; 215 183 216 end. 184 217
Note:
See TracChangeset
for help on using the changeset viewer.