Solved

Query System for Current logged in user

Posted on 2006-06-20
2
341 Views
Last Modified: 2010-04-01
I have a basic visual c++ 2005 console app and I need a way to query information from the computer on which the application is running that will return the username of the current user logged into windows. The machines will be running windows xp. I'm sure there is a system API for this, but I don't know which one.
0
Comment
Question by:inviser
  • 2
2 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 16946107
Hi inviser,
> I'm sure there is a system API for this, but I don't know which one.

You can use GetUserName API function

David Maisonave (Axter)
Cheers!
0
 
LVL 30

Accepted Solution

by:
Axter earned 500 total points
ID: 16946124
Example:
char UserName[256];
DWORD Size=255;

if  (!GetUserName(UserName,&Size))
{
  printf("cannot get user name\n");
  return;
}
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now