Changeset 404 for UpdateChecker


Ignore:
Timestamp:
Aug 13, 2012, 10:03:31 AM (12 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • UpdateChecker/UUpdateChecker.pas

    r379 r404  
    66
    77uses
    8   Windows, ShellApi, Forms, Classes, SysUtils, httpsend, DOM, XMLWrite, XMLRead, UXMLUtils,
     8  {$IFDEF Windows}Windows, ShellApi, {$ENDIF}Forms, Classes, SysUtils, httpsend, DOM, XMLWrite, XMLRead, UXMLUtils,
    99  FileUtil, Dialogs, Process, Blcksock, UFormDownloadProgress;
    1010
     
    2929    function DownloadHTTP(URL, TargetFile: string): Boolean;
    3030    function InstallerFileName: string;
    31     function IsWindowsAdmin: Boolean;
     31    function IsSystemAdmin: Boolean;
    3232    procedure SockStatus(Sender: TObject; Reason: THookSocketReason;
    3333    const Value: String);
     
    5858implementation
    5959
     60{$IFDEF Windows}
    6061const
    6162  SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)) ;
     
    6465  SECURITY_BUILTIN_DOMAIN_RID = $00000020;
    6566  DOMAIN_ALIAS_RID_ADMINS = $00000220;
     67{$ENDIF}
    6668
    6769procedure Register;
     
    145147begin
    146148  if FileExistsUTF8(InstallerFileName) then begin
    147     if not IsWindowsAdmin then
    148       ShellExecute(0, PChar('runas'), PChar(InstallerFileName),
    149         0, 0, SW_SHOWNORMAL)
     149    if not IsSystemAdmin then
     150      try
     151        Process := TProcess.Create(nil);
     152        Process.CommandLine := 'runas ' + InstallerFileName;
     153        Process.Options := Process.Options + [];
     154        Process.Execute;
     155      finally
     156        Process.Free;
     157      end
     158      //ShellExecute(0, PChar('runas'), PChar(InstallerFileName),
     159      //  0, 0, SW_SHOWNORMAL)
    150160    else
    151161    try
     
    232242end;
    233243
    234 function TUpdateChecker.IsWindowsAdmin: Boolean;
     244{$IFDEF Windows}
     245function TUpdateChecker.IsSystemAdmin: Boolean;
    235246var
    236247  hAccessToken: THandle;
     
    242253begin
    243254  Result := False;
    244 
    245255  bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken) ;
    246256  if not bSuccess then
     
    276286  end;
    277287end;
     288{$ELSE}
     289function TUpdateChecker.IsSystemAdmin: Boolean;
     290begin
     291  Result := False;
     292end;
     293
     294{$ENDIF}
    278295
    279296procedure TUpdateChecker.SockStatus(Sender: TObject; Reason: THookSocketReason;
Note: See TracChangeset for help on using the changeset viewer.