Created
March 30, 2016 15:29
-
-
Save manashmandal/ad1b61f075ad76ad6b76ca42de5624b4 to your computer and use it in GitHub Desktop.
Qt Quick 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "adminpriv.h" | |
#include "ui_adminpriv.h" | |
#include <QSettings> | |
#include <QDebug> | |
//Admin privilege checker string | |
#define ADMIN_TEST_STRING "HKEY_LOCAL_MACHINE" | |
#define ADMIN_DEFAULT_KEY "(Default)" | |
//If Admin privilege was activated or not | |
#define ADMIN_CHECK_OK "Administrator privilege was activated" | |
#define ADMIN_CHECK_FAILED "Administrator privilege not found" | |
AdminPriv::AdminPriv(QWidget *parent) : | |
QWidget(parent), | |
ui(new Ui::AdminPriv) | |
{ | |
ui->setupUi(this); | |
} | |
AdminPriv::~AdminPriv() | |
{ | |
delete ui; | |
} | |
void AdminPriv::on_checkButton_clicked() | |
{ | |
QSettings adminPrivSettings(ADMIN_TEST_STRING, QSettings::NativeFormat); | |
QVariant currentAdminStatus = adminPrivSettings.value(ADMIN_DEFAULT_KEY); | |
adminPrivSettings.setValue(ADMIN_DEFAULT_KEY, currentAdminStatus); | |
adminPrivSettings.sync(); | |
//Check for admin privilege mode | |
if (adminPrivSettings.status() == QSettings::AccessError){ | |
ui->statusLabel->setText(QString(ADMIN_CHECK_FAILED)); | |
} else { | |
ui->statusLabel->setText(QString(ADMIN_CHECK_OK)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment