Determine in Windows if the application is running with elevated privileges [duplicate]
Determine in Windows if the application is running with elevated privileges [duplicate]
This question already has an answer here:
This has been solved! This was accomplished with the following code:
#include <iostream>
#include <Shlobj.h>
int main()
{
if (!IsUserAnAdmin)
{
// Do stuff
}
if (IsUserAnAdmin)
{
// Do stuff
}
Thank you to everyone who commented on the post.
I'm in a bit of a rut with the C++ application I'm developing.
My application requires elevated privileges to function properly, and I'd like to be able to determine if such privileges are present upon runtime. How would I go about doing this? I would like to check immediately after the program is run, and throw an error or proceed with execution (of course)
Thank you for taking the time to respond.
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
@RetiredNinja Win32.
– Koi
2 days ago
The right way to do this is to add a manifest that says you need administrative privileges and let Windows handle it for you.
– Retired Ninja
2 days ago
Which platform?
– Retired Ninja
2 days ago