Test
This commit is contained in:
20
shared/User.h
Normal file
20
shared/User.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
static inline BOOL IsUserAdmin() {
|
||||
SID_IDENTIFIER_AUTHORITY authority = SECURITY_NT_AUTHORITY;
|
||||
PSID adminsSid;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if (!AllocateAndInitializeSid(&authority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &adminsSid)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!CheckTokenMembership(NULL, adminsSid, &result)) {
|
||||
result = FALSE;
|
||||
}
|
||||
|
||||
FreeSid(adminsSid);
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user