I've seen in other threads from 7 years ago that this is how you get the logged in user's name:
#include <iostream>
#include <string>
#include <windows.h>
#include <Lmcons.h>
using namespace std;
int
main()
{
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
GetUserName(username, &username_len);
std::cout << username << "\n" << &username_len;
}
But when i debug it, i get the errors: *argument of type "char " is incompatible with parameter of type "LPWSTR" and 'BOOL GetUserNameW(LPWSTR,LPDWORD)': cannot convert argument 1 from 'char [257]' to 'LPWSTR'