Advertisement
allen343434

Untitled

Feb 11th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. //in form load
  2. if (!sAdmin())
  3. {
  4. sProblemMSG("Run this program as Administrator");
  5. Application.Exit();
  6. }
  7.  
  8. public static bool sAdmin()
  9. {
  10. var identity = WindowsIdentity.GetCurrent();
  11. var principal = new WindowsPrincipal(identity);
  12. return principal.IsInRole(WindowsBuiltInRole.Administrator);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement