Make bit of code only run if the program has admin rights?

Okay, so I was wondering if there was a way to run code only if the program is running with admin rights.

Any help please? I want it to run code somewhat like this:

When you're running as admin
cout << "Thanks for running as admin. \n"

When you're not running as admin.
1
2
cout << "Please run as admin to continue. \n"
cin.ignore();
closed account (Dy7SLyTq)
windows or linux?
Windows. This is for a windows 8 trial refresh/kms activation tool.
Topic archived. No new replies allowed.