Changeset 169 for trunk/Packages/Common
- Timestamp:
- Jan 22, 2018, 11:00:53 AM (7 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UApplicationInfo.pas
r3 r169 14 14 TApplicationInfo = class(TComponent) 15 15 private 16 FDescription: string; 16 17 FIdentification: Byte; 17 18 FLicense: string; … … 33 34 constructor Create(AOwner: TComponent); override; 34 35 property Version: string read GetVersion; 36 function GetRegistryContext: TRegistryContext; 35 37 published 36 38 property Identification: Byte read FIdentification write FIdentification; … … 45 47 property EmailContact: string read FEmailContact write FEmailContact; 46 48 property AppName: string read FAppName write FAppName; 49 property Description: string read FDescription write FDescription; 47 50 property ReleaseDate: TDateTime read FReleaseDate write FReleaseDate; 48 51 property RegistryKey: string read FRegistryKey write FRegistryKey; … … 79 82 end; 80 83 84 function TApplicationInfo.GetRegistryContext: TRegistryContext; 85 begin 86 Result := TRegistryContext.Create(RegistryRoot, RegistryKey); 87 end; 88 81 89 end. -
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 -
trunk/Packages/Common/URegistry.pas
r3 r169 9 9 10 10 type 11 TRegistryRoot = (rrKeyClassesRoot = HKEY($80000000), 12 rrKeyCurrentUser = HKEY($80000001), 13 rrKeyLocalMachine = HKEY($80000002), 14 rrKeyUsers = HKEY($80000003), 15 rrKeyPerformanceData = HKEY($80000004), 16 rrKeyCurrentConfig = HKEY($80000005), 17 rrKeyDynData = HKEY($80000006)); 11 TRegistryRoot = (rrKeyClassesRoot, rrKeyCurrentUser, rrKeyLocalMachine, 12 rrKeyUsers, rrKeyPerformanceData, rrKeyCurrentConfig, rrKeyDynData); 18 13 19 14 { TRegistryContext } … … 23 18 Key: string; 24 19 class operator Equal(A, B: TRegistryContext): Boolean; 20 function Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; overload; 21 function Create(RootKey: HKEY; Key: string): TRegistryContext; overload; 25 22 end; 26 23 … … 43 40 end; 44 41 45 function RegContext(RootKey: HKEY; Key: string): TRegistryContext; 46 42 const 43 RegistryRootHKEY: array[TRegistryRoot] of HKEY = (HKEY_CLASSES_ROOT, 44 HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA, 45 HKEY_CURRENT_CONFIG, HKEY_DYN_DATA); 47 46 48 47 implementation 49 48 50 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;51 begin52 Result.RootKey := RootKey;53 Result.Key := Key;54 end;55 49 56 50 { TRegistryContext } … … 59 53 begin 60 54 Result := (A.Key = B.Key) and (A.RootKey = B.RootKey); 55 end; 56 57 function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext; 58 begin 59 Result.RootKey := RegistryRootHKEY[RootKey]; 60 Result.Key := Key; 61 end; 62 63 function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext; 64 begin 65 Result.RootKey := RootKey; 66 Result.Key := Key; 61 67 end; 62 68 -
trunk/Packages/Common/UScaleDPI.pas
r166 r169 325 325 AutoSize := False; 326 326 Height := ScaleY(Height, FromDPI.Y); 327 AutoSize := True; 327 328 end; 328 329 EndUpdate;
Note:
See TracChangeset
for help on using the changeset viewer.