[NEW_FEATURE] (Author: Andreas Jonsson) Change window title if program is running as administrator.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1115 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-09-09 17:30:24 +00:00
parent dda403cc6c
commit f552ef85a7
2 changed files with 23 additions and 0 deletions

View File

@ -152,6 +152,25 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N
{
_toolBar.initTheme(toolIconsDocRoot);
}
// Determine if user is administrator.
BOOL is_admin;
if(NppParameters::getInstance()->getWinVersion() >= WV_VISTA)
{
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
is_admin = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup);
if(is_admin)
{
if(!CheckTokenMembership(NULL, AdministratorsGroup, &is_admin))
is_admin = FALSE;
FreeSid(AdministratorsGroup);
}
}
else
is_admin = false;
_isAdministrator = is_admin ? true : false;
}
// ATTENTION : the order of the destruction is very important
@ -2531,6 +2550,9 @@ void Notepad_plus::setTitle()
result += TEXT(" - ");
result += _pPublicInterface->getClassName();
if(_isAdministrator)
result += TEXT(" [Administrator]");
::SendMessage(_pPublicInterface->getHSelf(), WM_SETTEXT, 0, (LPARAM)result.c_str());
}

View File

@ -416,6 +416,7 @@ private:
ButtonDlg _restoreButton;
bool _isFileOpening;
bool _isAdministrator;
ScintillaCtrls _scintillaCtrls4Plugins;