|
2013/9/19(Thu) 02:26:36|NO.57236
拾い物ですが
#module "IsUserAdmin_hsp"
#uselib "advapi32.dll"
#cfunc AllocateAndInitializeSid "AllocateAndInitializeSid" var, int, int, int, int, int, int, int, int, int, var
#cfunc CheckTokenMembership "CheckTokenMembership" int, int, var
#func FreeSid "FreeSid" int
#define SECURITY_BUILTIN_DOMAIN_RID 0x00000020
#define DOMAIN_ALIAS_RID_ADMINS 0x00000220
#defcfunc IsUserAdmin
sdim NtAuthority, 5
poke NtAuthority, 5, 5
b = AllocateAndInitializeSid(NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, AdministratorsGroup)
if b {
if CheckTokenMembership(0, AdministratorsGroup, b) == 0 {
b = 0
}
FreeSid AdministratorsGroup
}
return b
#global
// サンプル
if IsUserAdmin() {
mes "管理者権限です"
} else {
mes "管理者権限ではありません"
}
|