Aggiunto controllo di permessi di amministratore ad installazione

git-svn-id: svn://10.65.10.50/branches/R_10_00@22667 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-06-07 15:56:38 +00:00
parent 4be3336e19
commit 20fc8e1492
4 changed files with 45 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#include "ba1500.h"
#include "ba1600.h"
#include "ba1700a.h"
#include "ba1701.h"
// definizioni delle colonne dello sheet
#define C_MODULE 1
@ -380,6 +381,9 @@ int TInstaller_mask::precheck_modules(bool only_newer)
}
disable(DLG_USER);
check_enabled = false; //..ed uscire
if (!run_as_admin())
warning_box("Per installare il modulo è necessario eseguire l'applicazione come amministratore.");
}
} //if(modnumber>=0...
} //FOR_EACH_ARRAY_ROW...
@ -1645,6 +1649,12 @@ void TInstaller_mask::install_selection()
//richiesto aggiornamento da disco del modulo SY o del modulo SR da manutenzione/installazione moduli!
if (modulo == "sy" || modulo == "sr")
{
if (!run_as_admin())
{
error_box("Per installare il modulo sistema è necessario eseguire l'applicazione come amministratore");
break;
}
if (!internet)
{
bool file_copied = false;

24
ba/ba1701.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "ba1701.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
bool run_as_admin()
{
bool yes = true;
TOKEN_ELEVATION_TYPE elevationType = (TOKEN_ELEVATION_TYPE)0; // N/A for < Vista
OSVERSIONINFO VerInfo;
VerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&VerInfo);
if (VerInfo.dwMajorVersion >= 6) // If Vista or newer,
{
HANDLE hToken; // read elevation type
BOOL bOK = OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &hToken);
DWORD infoLen;
yes = GetTokenInformation(hToken, TokenElevationType, // type of info to retrieve
&elevationType, // receives return value
sizeof(elevationType), &infoLen) != 0; // receives returned length
}
return yes;
}

1
ba/ba1701.h Normal file
View File

@ -0,0 +1 @@
bool run_as_admin();

View File

@ -40,13 +40,17 @@ BEGIN
FLAGS "D"
END
SPREADSHEET F_SHEET 0 -3
SPREADSHEET F_SHEET
BEGIN
PROMPT 1 4 ""
ITEM "Campo@16"
ITEM "Campo@16"
END
ENDPAGE
TOOLBAR "Topbar" 0 0 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -13 -1 ""
@ -66,7 +70,7 @@ ENDPAGE
ENDMASK
PAGE "Fields" -1 -1 68 6
PAGE "Fields" -1 -1 68 4
STRING F_FLD_FROM 12
BEGIN
@ -80,6 +84,10 @@ BEGIN
FLAGS "B"
END
ENDPAGE
TOOLBAR "Topbar" 0 0 0 2
BUTTON DLG_OK 10 2
BEGIN
PROMPT -12 -1 ""