Changeset 404 for UpdateChecker/UUpdateChecker.pas
- Timestamp:
- Aug 13, 2012, 10:03:31 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
UpdateChecker/UUpdateChecker.pas
r379 r404 6 6 7 7 uses 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, 9 9 FileUtil, Dialogs, Process, Blcksock, UFormDownloadProgress; 10 10 … … 29 29 function DownloadHTTP(URL, TargetFile: string): Boolean; 30 30 function InstallerFileName: string; 31 function Is WindowsAdmin: Boolean;31 function IsSystemAdmin: Boolean; 32 32 procedure SockStatus(Sender: TObject; Reason: THookSocketReason; 33 33 const Value: String); … … 58 58 implementation 59 59 60 {$IFDEF Windows} 60 61 const 61 62 SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)) ; … … 64 65 SECURITY_BUILTIN_DOMAIN_RID = $00000020; 65 66 DOMAIN_ALIAS_RID_ADMINS = $00000220; 67 {$ENDIF} 66 68 67 69 procedure Register; … … 145 147 begin 146 148 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) 150 160 else 151 161 try … … 232 242 end; 233 243 234 function TUpdateChecker.IsWindowsAdmin: Boolean; 244 {$IFDEF Windows} 245 function TUpdateChecker.IsSystemAdmin: Boolean; 235 246 var 236 247 hAccessToken: THandle; … … 242 253 begin 243 254 Result := False; 244 245 255 bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken) ; 246 256 if not bSuccess then … … 276 286 end; 277 287 end; 288 {$ELSE} 289 function TUpdateChecker.IsSystemAdmin: Boolean; 290 begin 291 Result := False; 292 end; 293 294 {$ENDIF} 278 295 279 296 procedure TUpdateChecker.SockStatus(Sender: TObject; Reason: THookSocketReason;
Note:
See TracChangeset
for help on using the changeset viewer.