I want to get current login user name in windows xp, windows 7, in c++. How can I do this? Is there any handy API without authority problem? Many thanks!
views:
65answers:
2
+2
Q:
Is There any handy way to get windows XP, windows 7 current login User Name in VC? Many Thanks!
A:
This should work:
char sz[256];
GetEnvironmentVariable ("USERNAME", sz, 256);
Tarydon
2010-02-22 02:26:12
-1: `SET USERNAME=FOO`
John Saunders
2010-02-22 02:31:32
set USERNAME=AnyFakeNameIWantToMakeUp.
No Refunds No Returns
2010-02-22 02:51:25
+4
A:
Use the Win32 API GetUserName or GetUserNameEx if you want a little more options.
Brian R. Bondy
2010-02-22 02:30:14