You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
377 B
20 lines
377 B
#include <windows.h>
|
|
#include <Lmcons.h>
|
|
#include <wchar.h>
|
|
|
|
int wmain(void) {
|
|
|
|
wchar_t username[UNLEN+1];
|
|
DWORD len = sizeof(username) / sizeof(wchar_t);
|
|
|
|
int r = GetUserNameW(username, &len);
|
|
|
|
if (r == 0) {
|
|
wprintf(L"Failed to get username %ld", GetLastError());
|
|
return 1;
|
|
}
|
|
|
|
wprintf(L"User name: %ls\n", username);
|
|
|
|
return 0;
|
|
}
|
|
|