You've already forked lazarus-ccr
Routine added that prevents non-admin Windows users from updating
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5665 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,11 +4,11 @@
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="10"/>
|
||||
<BuildModes Active="Win32"/>
|
||||
<Units Count="17">
|
||||
<Units Count="18">
|
||||
<Unit0>
|
||||
<Filename Value="testapp.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<CursorPos X="33" Y="27"/>
|
||||
<UsageCount Value="44"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -19,7 +19,6 @@
|
||||
<ComponentName Value="mainform"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="64"/>
|
||||
<CursorPos X="19" Y="103"/>
|
||||
<UsageCount Value="44"/>
|
||||
@ -38,7 +37,7 @@
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\lazautoupdate_httpclient.pas"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<CursorPos X="97" Y="12"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
@ -47,13 +46,13 @@
|
||||
<Filename Value="..\ulazautoupdate.pas"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<WindowIndex Value="1"/>
|
||||
<TopLine Value="352"/>
|
||||
<CursorPos X="46" Y="373"/>
|
||||
<TopLine Value="1766"/>
|
||||
<CursorPos X="111" Y="1791"/>
|
||||
<ExtraEditorCount Value="2"/>
|
||||
<ExtraEditor1>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="1145"/>
|
||||
<CursorPos X="11" Y="1235"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<TopLine Value="1163"/>
|
||||
<CursorPos X="11" Y="1253"/>
|
||||
</ExtraEditor1>
|
||||
<ExtraEditor2>
|
||||
<EditorIndex Value="-1"/>
|
||||
@ -102,7 +101,7 @@
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\..\..\applications\foobot\monitor\umainform.pas"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="25"/>
|
||||
<CursorPos X="25" Y="55"/>
|
||||
<UsageCount Value="19"/>
|
||||
@ -117,7 +116,7 @@
|
||||
<Unit12>
|
||||
<Filename Value="..\versionsupport.pas"/>
|
||||
<UnitName Value="VersionSupport"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<TopLine Value="25"/>
|
||||
<CursorPos X="71" Y="44"/>
|
||||
<UsageCount Value="16"/>
|
||||
@ -153,6 +152,16 @@
|
||||
<UsageCount Value="11"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit16>
|
||||
<Unit17>
|
||||
<Filename Value="C:\NewPascal\projects\snippets\usefulunits\uuser.pas"/>
|
||||
<UnitName Value="uUser"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="6"/>
|
||||
<CursorPos Y="25"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit17>
|
||||
</Units>
|
||||
<General>
|
||||
<ActiveWindowIndexAtStart Value="1"/>
|
||||
|
@ -127,6 +127,12 @@ const
|
||||
C_LOCALUPDATER = 'lauupdatewin32.exe';{$ENDIF}
|
||||
{$IFDEF CPU64}C_UPDATER = 'updatehmwin64.exe';
|
||||
C_LOCALUPDATER = 'lauupdatewin64.exe';{$ENDIF}
|
||||
// Windows Constants
|
||||
CONST
|
||||
GENERIC_READ = $80000000;
|
||||
GENERIC_WRITE = $40000000;
|
||||
GENERIC_EXECUTE = $20000000;
|
||||
GENERIC_ALL = $10000000;
|
||||
{$ENDIF}
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF CPU32}C_UPDATER = 'updatehmlinux32';
|
||||
@ -339,7 +345,6 @@ type
|
||||
// Set this property before using methods
|
||||
property SFProjectName: string read fSourceForgeProjectName
|
||||
write SetSourceForgeProjectName;
|
||||
// Only auSourceForge at V0.0.1
|
||||
// For when fProjectType = auOther
|
||||
// Fully qualified URL (not including the filename).
|
||||
property auOtherSourceURL: string read fauOtherSourceURL write SetauOtherSourceURL;
|
||||
@ -353,9 +358,9 @@ type
|
||||
property AutoUpdateVersion: string read fComponentVersion;
|
||||
// Zipfile contains a whole directory tree (relative to App Directory)
|
||||
property CopyTree: boolean read fCopyTree write fCopyTree default True;
|
||||
// Default is 'updates' *must be the same in SourceForge file section*
|
||||
// Default is 'updates' *must be the same in SourceForge file section or GitHub Branch subfolder*
|
||||
property UpdatesFolder: string read fUpdatesFolder write fUpdatesFolder;
|
||||
// Default=versions.ini File in SourceForge /updates folder
|
||||
// Default=versions.ini File in SourceForge/GitHub /updates folder
|
||||
property VersionsININame: string read fVersionsININame write fVersionsININame;
|
||||
// Default is to modify parent form's caption during downloads
|
||||
property ShowUpdateInCaption: boolean read fShowUpdateInCaption
|
||||
@ -370,10 +375,15 @@ type
|
||||
write fDownloadCountLimit;
|
||||
// Default is application filename.zip
|
||||
property ZipfileName: string read fZipfileName write fZipfileName;
|
||||
// Name of Console app
|
||||
property UpdateExe:String read fUpdateExe;
|
||||
// Name of Console app
|
||||
property UpdateExeSilent:String read fUpdateSilentExe;
|
||||
// Main project name/UserName
|
||||
property GitHubProjectname:String read fGitHubProjectName write fGitHubProjectName;
|
||||
// Name of your GitHub repository within the project/username
|
||||
Property GitHubRepositoryName:String read fGitHubRepositoryName write fGitHubRepositoryName;
|
||||
// Default=master but any branchname is OK
|
||||
Property GitHubBranch:String read fGitHubBranch write fGitHubBranch;
|
||||
end;
|
||||
|
||||
@ -471,7 +481,19 @@ procedure TLazAutoUpdate.DebugTest;
|
||||
begin
|
||||
ShowMessage(fApplicationVersionString);
|
||||
end;
|
||||
{$IFDEF WINDOWS}
|
||||
function IsWindowsAdmin: boolean;
|
||||
var
|
||||
hSC: THandle;
|
||||
begin
|
||||
Result := True;
|
||||
hSC := OpenSCManager(nil, nil, GENERIC_READ or GENERIC_WRITE or GENERIC_EXECUTE);
|
||||
|
||||
if (hSC = 0) then
|
||||
Result := False;
|
||||
CloseServiceHandle(hSC);
|
||||
end;
|
||||
{$ENDIF}
|
||||
constructor TLazAutoUpdate.Create(AOwner: TComponent);
|
||||
var
|
||||
sz: string;
|
||||
@ -1762,6 +1784,17 @@ var
|
||||
szParams: string;
|
||||
begin
|
||||
Result := False;
|
||||
{$IFDEF WINDOWS}
|
||||
If NOT IsWindowsAdmin then
|
||||
begin
|
||||
szParams:='Only Windows users whith Administrator status can update this application.' + lineending;
|
||||
szParams+='Please log off, then log on as an administrator (or switch users to an administrator account),' + lineending;
|
||||
szParams+='then try again. This restriction is for the safety and security of your Windows system.' + lineending;
|
||||
szParams+='Click OK to continue';
|
||||
MessageDlg('Application update',szParams,mtInformation,[MBOK],0);
|
||||
Exit;
|
||||
end;
|
||||
{$ENDIF}
|
||||
szAppDir := AppendPathDelim(ExtractFilePath(fAppFilename));
|
||||
|
||||
// read the VMT once
|
||||
|
Reference in New Issue
Block a user