By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,955 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

How to find Logged In user type in C/C++?

P: 26
Hello All,
Please can anybody help me how to find the system user type in c/c++ code...? I just want to do some operation if the user is system admin... If there is some other way to find system admin, please tell me and help me in solving this...
Nov 30 '10 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 5K+
P: 8,916
There is no way to do it in standard C/C++ you would need to call some platform dependant OS provided API if there is one.
Nov 30 '10 #2

P: 26
Thank You Banfa... But can you help me a little more in doing this...??? Please...
Nov 30 '10 #3

P: 207
What OS are you using snatusapi? That will help us give you a clue...
Nov 30 '10 #4

P: 26
I'm using windows XP.. but i might use that call in most of the versions of windows...
Nov 30 '10 #5

P: 687
It may not matter who is logged in, but what under user your process is running.
Find the user the process is running under and then find if it belongs to administrators group? Then search for functions to do this on microsoft site, starting e.g. from here
Googled a bit more ... -
OpenProcess (PID) -> process handle
OpenProcessToken (process handle) -> access token
GetTokenInformation (access token) -> token info
LookupAccountSid (token info.SID) -> "domain\user"
Nov 30 '10 #6

P: 26
Thank you newb16... I will try this once... Thanks a lot for the idea...
Dec 1 '10 #7

Post your reply

Sign in to post your reply or Sign up for a free account.