Administrator Privileges
-
Hi All I need to block or show message when application run as Administrator.Is it possible? Please help me
-
Hi All I need to block or show message when application run as Administrator.Is it possible? Please help me
-
-
Hey i use code which is given in MSDN.I use like this
bool CCheckApp::IsUserAdmin(void)
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &b))
{
AfxMessageBox("Test");
b = FALSE;
}
FreeSid(AdministratorsGroup);
}return(b);
}
And call in
BOOL CCheckApp::InitInstance()
{
.....
..
IsUserAdmin();}
i am wrong or right.Please help me
-
Hey i use code which is given in MSDN.I use like this
bool CCheckApp::IsUserAdmin(void)
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &b))
{
AfxMessageBox("Test");
b = FALSE;
}
FreeSid(AdministratorsGroup);
}return(b);
}
And call in
BOOL CCheckApp::InitInstance()
{
.....
..
IsUserAdmin();}
i am wrong or right.Please help me
Why not ? :) You could modify the last line:
return (FALSE != b); // to prevent a possible warning
virtual void BeHappy() = 0;
-
Why not ? :) You could modify the last line:
return (FALSE != b); // to prevent a possible warning
virtual void BeHappy() = 0;
-
Try it also in the admin mode at the switched-on UAC :)
virtual void BeHappy() = 0;