Solved

Query System for Current logged in user

Posted on 2006-06-20
2
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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