Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in form load
- if (!sAdmin())
- {
- sProblemMSG("Run this program as Administrator");
- Application.Exit();
- }
- public static bool sAdmin()
- {
- var identity = WindowsIdentity.GetCurrent();
- var principal = new WindowsPrincipal(identity);
- return principal.IsInRole(WindowsBuiltInRole.Administrator);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement