Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using visual c++, how can I capture

Status
Not open for further replies.

rickylui

Technical User
Aug 21, 2002
3
0
0
US
Using visual c++, how can I capture the USERNAME of the currently logged in user?... I need to change to capture tha USERNAME and then change to that USERNAME's directory - within my coding, in order to write / update a file whenever each specifid USERNAME logs in. ....one file per the username?
 
to get the username:

#include <windows.h>
#include <lmcons.h>

char Username[UNLEN+1];
DWORD cbUsername = sizeof ( Username );
if ( !GetUserName ( Username, &cbUsername ))
{ // failure, call GetLastError ( ) to find out why
}

Marcel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top