Changeset 169 for trunk/Packages


Ignore:
Timestamp:
Jan 22, 2018, 11:00:53 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
Location:
trunk/Packages/Common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UApplicationInfo.pas

    r3 r169  
    1414  TApplicationInfo = class(TComponent)
    1515  private
     16    FDescription: string;
    1617    FIdentification: Byte;
    1718    FLicense: string;
     
    3334    constructor Create(AOwner: TComponent); override;
    3435    property Version: string read GetVersion;
     36    function GetRegistryContext: TRegistryContext;
    3537  published
    3638    property Identification: Byte read FIdentification write FIdentification;
     
    4547    property EmailContact: string read FEmailContact write FEmailContact;
    4648    property AppName: string read FAppName write FAppName;
     49    property Description: string read FDescription write FDescription;
    4750    property ReleaseDate: TDateTime read FReleaseDate write FReleaseDate;
    4851    property RegistryKey: string read FRegistryKey write FRegistryKey;
     
    7982end;
    8083
     84function TApplicationInfo.GetRegistryContext: TRegistryContext;
     85begin
     86  Result := TRegistryContext.Create(RegistryRoot, RegistryKey);
     87end;
     88
    8189end.
  • trunk/Packages/Common/UCommon.pas

    r141 r169  
    6363procedure OpenWebPage(URL: string);
    6464procedure OpenFileInShell(FileName: string);
    65 procedure ExecuteProgram(CommandLine: string);
     65procedure ExecuteProgram(Executable: string; Parameters: array of string);
    6666procedure FreeThenNil(var Obj);
    6767function RemoveQuotes(Text: string): string;
     
    7070function GetDirCount(Dir: string): Integer;
    7171function MergeArray(A, B: array of string): TArrayOfString;
     72function LoadFileToStr(const FileName: TFileName): AnsiString;
    7273
    7374
     
    111112  Path := IncludeTrailingPathDelimiter(APath);
    112113
    113   Find := FindFirst(UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec);
     114  Find := FindFirst(Path + AFileSpec, faAnyFile xor faDirectory, SearchRec);
    114115  while Find = 0 do begin
    115     DeleteFile(Path + UTF8Encode(SearchRec.Name));
     116    DeleteFile(Path + SearchRec.Name);
    116117
    117118    Find := SysUtils.FindNext(SearchRec);
     
    428429end;
    429430
    430 procedure ExecuteProgram(CommandLine: string);
     431procedure ExecuteProgram(Executable: string; Parameters: array of string);
    431432var
    432433  Process: TProcess;
     434  I: Integer;
    433435begin
    434436  try
    435437    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]);
    437441    Process.Options := [poNoConsole];
    438442    Process.Execute;
     
    455459procedure OpenFileInShell(FileName: string);
    456460begin
    457   ExecuteProgram('cmd.exe /c start "' + FileName + '"');
     461  ExecuteProgram('cmd.exe', ['/c', 'start', FileName]);
    458462end;
    459463
     
    492496end;
    493497
     498function LoadFileToStr(const FileName: TFileName): AnsiString;
     499var
     500  FileStream: TFileStream;
     501  Read: Integer;
     502begin
     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;
     514end;
     515
    494516
    495517
  • trunk/Packages/Common/URegistry.pas

    r3 r169  
    99
    1010type
    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);
    1813
    1914  { TRegistryContext }
     
    2318    Key: string;
    2419    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;
    2522  end;
    2623
     
    4340  end;
    4441
    45 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;
    46 
     42const
     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);
    4746
    4847implementation
    4948
    50 function RegContext(RootKey: HKEY; Key: string): TRegistryContext;
    51 begin
    52   Result.RootKey := RootKey;
    53   Result.Key := Key;
    54 end;
    5549
    5650{ TRegistryContext }
     
    5953begin
    6054  Result := (A.Key = B.Key) and (A.RootKey = B.RootKey);
     55end;
     56
     57function TRegistryContext.Create(RootKey: TRegistryRoot; Key: string): TRegistryContext;
     58begin
     59  Result.RootKey := RegistryRootHKEY[RootKey];
     60  Result.Key := Key;
     61end;
     62
     63function TRegistryContext.Create(RootKey: HKEY; Key: string): TRegistryContext;
     64begin
     65  Result.RootKey := RootKey;
     66  Result.Key := Key;
    6167end;
    6268
  • trunk/Packages/Common/UScaleDPI.pas

    r166 r169  
    325325      AutoSize := False;
    326326      Height := ScaleY(Height, FromDPI.Y);
     327      AutoSize := True;
    327328    end;
    328329    EndUpdate;
Note: See TracChangeset for help on using the changeset viewer.