Click here to Skip to main content
15,910,661 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: sizeof Operator Pin
Erudite_Eric28-Nov-13 22:48
Erudite_Eric28-Nov-13 22:48 
GeneralRe: sizeof Operator Pin
Stefan_Lang29-Nov-13 0:05
Stefan_Lang29-Nov-13 0:05 
GeneralRe: sizeof Operator Pin
jschell2-Dec-13 9:40
jschell2-Dec-13 9:40 
Questionhow to know the process is run with admin privileges or not? Pin
Le@rner25-Nov-13 23:51
Le@rner25-Nov-13 23:51 
AnswerRe: how to know the process is run with admin privileges or not? Pin
bjdestiny26-Nov-13 0:27
professionalbjdestiny26-Nov-13 0:27 
GeneralRe: how to know the process is run with admin privileges or not? Pin
Le@rner26-Nov-13 0:37
Le@rner26-Nov-13 0:37 
AnswerRe: how to know the process is run with admin privileges or not? Pin
Richard Andrew x6426-Nov-13 6:58
professionalRichard Andrew x6426-Nov-13 6:58 
AnswerRe: how to know the process is run with admin privileges or not? Pin
«_Superman_»26-Nov-13 19:53
professional«_Superman_»26-Nov-13 19:53 
Run this piece of code -
HANDLE hProcess = ::GetCurrentProcess();

HANDLE hToken;
::OpenProcessToken(hProcess, TOKEN_QUERY, &hToken);

PTOKEN_ELEVATION_TYPE ele = 0;
DWORD dwLen;
::GetTokenInformation(hToken, TokenElevationType, (LPVOID)ele, 0, &dwLen);

ele = (PTOKEN_ELEVATION_TYPE)::HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwLen);
::GetTokenInformation(hToken, TokenElevationType, (LPVOID)ele, dwLen, &dwLen);

ele will be TokenElevationTypeFull if run with admin privileges and TokenElevationTypeLimited if not.

The above code will check the current process.
To check for other processes, as others have said, you need to open the process to get its handle.
«_Superman 
I love work. It gives me something to do between weekends.


Microsoft MVP (Visual C++) (October 2009 - September 2013)

Polymorphism in C

GeneralRe: how to know the process is run with admin privileges or not? Pin
Le@rner26-Nov-13 22:33
Le@rner26-Nov-13 22:33 
QuestionGet user name Pin
john563225-Nov-13 6:25
john563225-Nov-13 6:25 
QuestionRe: Get user name Pin
David Crow25-Nov-13 7:07
David Crow25-Nov-13 7:07 
AnswerRe: Get user name Pin
«_Superman_»25-Nov-13 19:35
professional«_Superman_»25-Nov-13 19:35 
QuestionC-Style Exports Pin
Richard Andrew x6424-Nov-13 15:15
professionalRichard Andrew x6424-Nov-13 15:15 
AnswerRe: C-Style Exports Pin
Joe Woodbury24-Nov-13 16:45
professionalJoe Woodbury24-Nov-13 16:45 
GeneralRe: C-Style Exports Pin
Richard Andrew x6424-Nov-13 16:51
professionalRichard Andrew x6424-Nov-13 16:51 
GeneralRe: C-Style Exports Pin
Richard Andrew x6424-Nov-13 16:53
professionalRichard Andrew x6424-Nov-13 16:53 
AnswerRe: C-Style Exports Pin
«_Superman_»24-Nov-13 18:52
professional«_Superman_»24-Nov-13 18:52 
GeneralRe: C-Style Exports Pin
Richard Andrew x6425-Nov-13 6:19
professionalRichard Andrew x6425-Nov-13 6:19 
GeneralRe: C-Style Exports Pin
«_Superman_»25-Nov-13 19:26
professional«_Superman_»25-Nov-13 19:26 
QuestionHow to draw lines in a translucent window Pin
chengmingma22-Nov-13 16:42
chengmingma22-Nov-13 16:42 
AnswerRe: How to draw lines in a translucent window Pin
enhzflep22-Nov-13 18:50
enhzflep22-Nov-13 18:50 
Question[SOLVED] What is the x64 #define? Pin
Richard Andrew x6422-Nov-13 11:34
professionalRichard Andrew x6422-Nov-13 11:34 
SuggestionRe: [SOLVED] What is the x64 #define? Pin
Randor 22-Nov-13 12:51
professional Randor 22-Nov-13 12:51 
GeneralRe: [SOLVED] What is the x64 #define? Pin
Richard Andrew x6422-Nov-13 12:54
professionalRichard Andrew x6422-Nov-13 12:54 
GeneralRe: [SOLVED] What is the x64 #define? Pin
Randor 22-Nov-13 13:13
professional Randor 22-Nov-13 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.