- Timestamp:
- Jan 3, 2012, 10:31:59 AM (13 years ago)
- Location:
- Common
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UCommon.pas
r290 r305 61 61 procedure DeleteFiles(APath, AFileSpec: string); 62 62 procedure OpenWebPage(URL: string); 63 procedure OpenFileInShell(FileName: string); 64 procedure ExecuteProgram(CommandLine: string); 63 65 64 66 … … 285 287 L := MAX_USERNAME_LENGTH + 2; 286 288 SetLength(Result, L); 287 if Windows.GetUserName(PChar(Result), L) and (L > 0) then 288 SetLength(Result, StrLen(PChar(Result))) else 289 Result := ''; 289 if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin 290 SetLength(Result, StrLen(PChar(Result))); 291 Result := UTF8Encode(Result); 292 end else Result := ''; 290 293 end; 291 294 … … 365 368 end; 366 369 370 procedure ExecuteProgram(CommandLine: string); 371 var 372 Process: TProcess; 373 begin 374 try 375 Process := TProcess.Create(nil); 376 Process.CommandLine := CommandLine; 377 Process.Options := [poNoConsole]; 378 Process.Execute; 379 finally 380 Process.Free; 381 end; 382 end; 383 367 384 procedure OpenWebPage(URL: string); 368 385 var … … 376 393 //Process.Executable := Browser; 377 394 //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]); 378 Process.Executable := 'cmd.exe'; 379 Process.Parameters.Add('/c'); 380 Process.Parameters.Add('start'); 381 Process.Parameters.Add(URL); 395 Process.CommandLine := 'cmd.exe /c start ' + URL; 382 396 Process.Options := [poNoConsole]; 383 397 Process.Execute; … … 387 401 end; 388 402 403 procedure OpenFileInShell(FileName: string); 404 begin 405 ExecuteProgram('cmd.exe /c start ' + FileName); 406 end; 389 407 390 408 initialization -
Common/UDebugLog.pas
r295 r305 45 45 46 46 implementation 47 48 resourcestring 49 SFileNameNotDefined = 'Filename not defined'; 47 50 48 51 procedure Register; … … 100 103 LogFile: TFileStream; 101 104 begin 105 if FileName = '' then raise Exception.Create(SFileNameNotDefined); 102 106 try 103 107 if ExtractFileDir(FileName) <> '' then … … 131 135 TDebugLogItem(List[I]).Free; 132 136 Items.Free; 133 inherited Destroy;137 inherited; 134 138 end; 135 139 -
Common/UThreading.pas
r295 r305 17 17 TVirtualThread = class 18 18 private 19 function GetFinished: Boolean; virtual; abstract; 19 20 function GetFreeOnTerminate: Boolean; virtual; abstract; 20 21 function GetPriority: TThreadPriority; virtual; abstract; … … 42 43 property Priority: TThreadPriority read GetPriority write SetPriority; 43 44 property Terminated: Boolean read GetTerminated write SetTerminated; 45 property Finished: Boolean read GetFinished; 44 46 property ThreadId: Integer read GetThreadId; 45 47 end; … … 61 63 private 62 64 FTerminated: Boolean; 65 FFinished: Boolean; 63 66 FThread: TListedThreadExecute; 67 function GetFinished: Boolean; override; 64 68 function GetFreeOnTerminate: Boolean; override; 65 69 function GetPriority: TThreadPriority; override; … … 172 176 end; 173 177 174 175 178 { TThreadList } 176 179 … … 196 199 begin 197 200 try 198 Parent.Execute; 199 except 200 on E: Exception do 201 if Assigned(OnException) then 202 OnException(Parent.FThread, E); 201 try 202 Parent.Execute; 203 except 204 on E: Exception do 205 if Assigned(OnException) then 206 OnException(Parent.FThread, E); 207 end; 208 finally 209 Parent.FFinished := True; 203 210 end; 204 211 end; 205 212 206 213 { TListedThread } 214 215 function TListedThread.GetFinished: Boolean; 216 begin 217 Result := FFinished; 218 end; 207 219 208 220 function TListedThread.GetFreeOnTerminate: Boolean; … … 255 267 const StackSize: SizeUInt); 256 268 begin 269 FFinished := False; 270 FTerminated := False; 271 257 272 FThread := TListedThreadExecute.Create(True, StackSize); 258 273 FThread.Parent := Self;
Note:
See TracChangeset
for help on using the changeset viewer.