The solution can be found there:
http://stackoverflow.com/questions/95912/how-can-i-detect-if-my-process-is-running-uac-elevated-or-not[
^].
[EDIT]
This is not the same as checking
IsUserAnAdmin
:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776463%28v=vs.85%29.aspx[
^].
This API merely checks up if the user is in the Administrator's group. This is not what you need: to get elevated privileges, the user does not have to be in this group, and the privileges can be denied (via UAC) is the user is a member of this group.
I think this API was only useful for OS before Vista and Windows Server 2008 when UAC was introduced. For more information, please see:
http://en.wikipedia.org/wiki/User_Account_Control[
^].
[END EDIT]
However, if you properly devise your manifest, you don't really need to check it up. You can consider the functionality you need is already built in UAC in the following sense: if the user can get a requested privilege and confirm in the UAC confirmation dialog which appears automatically, the application will be executed, always with elevated privileges; in all other cases, if cannot be executed at all. I think if this functionality can be enough for your purpose, it's always better.
If do understand that in certain cases you really need to check up the elevation in the application code. One simple example is: if it is granted the elevated privileges, you show full set of operations, if not, you hide or, better, disable some items from its UI. I just don't see where you would need it in your case. You know better, of course.
—SA