Get Windows XP, Windows 7 current login Username in VC

I want to get the current login name in windows xp, windows 7, in C ++. How can i do this? Is there a user-friendly API without authority?

+3
source share
2 answers

Use the Win32 API GetUserName or GetUserNameEx if you want a bit more options.

+4
source

This should work:

char sz[256];
GetEnvironmentVariable ("USERNAME", sz, 256);
0
source

Source: https://habr.com/ru/post/1733825/


All Articles