Add(MainForm,2953706,322,147) { } Add(InlineCode,3163755,259,147) { WorkPoints=#9:IsAsAdmin| EventPoints=#5:onRes| Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses kol,windows,Share,Debug;|0:|5:const|76:SECURITY_NT_AUTHORITY: TSIDIdentifierAuthority =(Value: (0, 0, 0, 0, 0, 5));|40:SECURITY_BUILTIN_DOMAIN_RID = $00000020;|36:DOMAIN_ALIAS_RID_ADMINS = $00000220;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|0:|9: public|21: onRes:THI_Event;|50: procedure IsAsAdmin(var dt:TData; idx: word);|0:|5: end;|0:|14:implementation|0:|26:function IsAdmin: Boolean;|3:var|24: hAccessToken: THandle;|26: ptgGroups: PTokenGroups;|26: dwInfoBufferSize: DWORD;|27: psidAdministrators: PSID;|13: x: Integer;|17: bSuccess: BOOL;|5:begin|18: Result := False;|80: bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True,hAccessToken);|22: if not bSuccess then|7: begin|41: if GetLastError = ERROR_NO_TOKEN then|80: bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY,hAccessToken);|6: end;|18: if bSuccess then|7: begin|28: GetMem(ptgGroups, 1024);|97: bSuccess := GetTokenInformation(hAccessToken, TokenGroups,ptgGroups, 1024, dwInfoBufferSize);|30: CloseHandle(hAccessToken);|20: if bSuccess then|11: begin|58: AllocateAndInitializeSid(SECURITY_NT_AUTHORITY, 2,|86: SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS,|71: 0, 0, 0, 0, 0, 0, psidAdministrators);|5:{$R-}|42: for x := 0 to ptgGroups.GroupCount -1 do|65: if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then|9: begin|21: Result := True;|12: Break;|8: end;|5:{$R+}|31: FreeSid(psidAdministrators);|6: end;|22: FreeMem(ptgGroups);|6: end;|4:end;|0:|32:procedure THiAsmClass.IsAsAdmin;|5:begin|38: if IsAdmin then _hi_onEvent(onRes,1)|30: else _hi_onEvent(onRes,0);|0:|4:end;|0:|4:end.| link(onRes,2953706:doCaption,[]) } Add(Button,13803126,203,147) { Left=185 Top=145 link(onClick,3163755:IsAsAdmin,[]) }