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
C++Programming Theory

Avatar of undefined
Last Comment
Zoppo
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
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
Avatar of Zoppo
Zoppo
Flag of Germany image

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 ...
C++
C++

C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.

58K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo