Changeset 169 for trunk/Packages/Common/UCommon.pas
- Timestamp:
- Jan 22, 2018, 11:00:53 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UCommon.pas
r141 r169 63 63 procedure OpenWebPage(URL: string); 64 64 procedure OpenFileInShell(FileName: string); 65 procedure ExecuteProgram( CommandLine:string);65 procedure ExecuteProgram(Executable: string; Parameters: array of string); 66 66 procedure FreeThenNil(var Obj); 67 67 function RemoveQuotes(Text: string): string; … … 70 70 function GetDirCount(Dir: string): Integer; 71 71 function MergeArray(A, B: array of string): TArrayOfString; 72 function LoadFileToStr(const FileName: TFileName): AnsiString; 72 73 73 74 … … 111 112 Path := IncludeTrailingPathDelimiter(APath); 112 113 113 Find := FindFirst( UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec);114 Find := FindFirst(Path + AFileSpec, faAnyFile xor faDirectory, SearchRec); 114 115 while Find = 0 do begin 115 DeleteFile(Path + UTF8Encode(SearchRec.Name));116 DeleteFile(Path + SearchRec.Name); 116 117 117 118 Find := SysUtils.FindNext(SearchRec); … … 428 429 end; 429 430 430 procedure ExecuteProgram( CommandLine:string);431 procedure ExecuteProgram(Executable: string; Parameters: array of string); 431 432 var 432 433 Process: TProcess; 434 I: Integer; 433 435 begin 434 436 try 435 437 Process := TProcess.Create(nil); 436 Process.CommandLine := CommandLine; 438 Process.Executable := Executable; 439 for I := 0 to Length(Parameters) - 1 do 440 Process.Parameters.Add(Parameters[I]); 437 441 Process.Options := [poNoConsole]; 438 442 Process.Execute; … … 455 459 procedure OpenFileInShell(FileName: string); 456 460 begin 457 ExecuteProgram('cmd.exe /c start "' + FileName + '"');461 ExecuteProgram('cmd.exe', ['/c', 'start', FileName]); 458 462 end; 459 463 … … 492 496 end; 493 497 498 function LoadFileToStr(const FileName: TFileName): AnsiString; 499 var 500 FileStream: TFileStream; 501 Read: Integer; 502 begin 503 Result := ''; 504 FileStream := TFileStream.Create(FileName, fmOpenRead); 505 try 506 if FileStream.Size > 0 then begin 507 SetLength(Result, FileStream.Size); 508 Read := FileStream.Read(Pointer(Result)^, FileStream.Size); 509 SetLength(Result, Read); 510 end; 511 finally 512 FileStream.Free; 513 end; 514 end; 515 494 516 495 517
Note:
See TracChangeset
for help on using the changeset viewer.