Create username.c

This commit is contained in:
janbodnar 2016-01-31 13:54:33 +01:00
parent a6f48c2709
commit b42a41fb2f

20
system/username.c Normal file
View File

@ -0,0 +1,20 @@
#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;
}