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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the profile name of a user in NT? 3

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
Hallo. I have an exe that runs from everyone's StartUp folder in their profile. This runs in their desktop, so I can extract the name & write it to an ini file & retrieve it whenever necessary.
However, I use this information to keep profiles etc. cleaned up (limited space on NT4), and this approach seems to me to hold alot of potential for disaster.
Does anyone know where the current profile users name is stored on NT? Or where the SID is at & how I can cross reference it with their name? If I could make a confident call before each process, I'd sleep a great deal easier.
Any & all help gratefully received.

Cheers,
Douglas JL.

If it don't make you laugh, it ain't true.
 
Try the environment-Variable "Username". Use the function getenv.

hnd
hasso55@yahoo.com

 
That sounds like the job.
Thanks alot, man.

Douglas.

If it don't make you laugh, it ain't true.
 
You can use LanManager API (from lm.h):

WKSTA_USER_INFO_0 *pBuf = NULL;
NetWkstaUserGetInfo(NULL, 0, (BYTE**)&pBuf);

Get username from the structure :
pBuf->wkui0_username

Eventually add following code, because of Unicode coding :

#ifndef UNICODE
#define UNICODE
#endif

 
would this work ?
I thinkl I have used something like this on win2000 once.

ExpandEnvironmentStrings( "\%USERPROFILE\%", sBuf, lBufSize );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top