Link to home
Create AccountLog in
Avatar of sarantm
sarantm

asked on

Getting the user details of a thread at runtime

Hi,

I am having a C++ based COM application which is a multi-threaded application. A number of threads are spawned from main process, I would like to retrieve the user details of a thread at run-time, which functions should be used.

Thanks,
Saravanan
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of sarantm
sarantm

ASKER

Hello ZOPPO,

I used GetUserNameEx function to retrieve user name and domain of given thread. This is much more easier than your approach.

What is advantage over your approach and mine.

Tnx,
Saravanan
Well, I posted the above comment since from your question it wasn't really clear what exactly you need.

The 'GetUserNameEx' returns info about the calling thread - my suggestion can be used to retrieve info about any running thread (as long as the calling thread has permissions to query info about that thread) - so, you could even i.e. use it to enumerate through all threads running on a machine and determine the user who started these threads.

If you just need the info within the running thread for sure 'GetUserNameEx' is much easier ...