I would like to know how to get the currenty logged on user's name as a wstring.
I only found LPWSTR examples like that:
#include <iostream>
#include <windows.h>
#include <Lmcons.h>
using namespace std;
int main()
{
wchar_t name[UNLEN+1];
DWORD size = UNLEN + 1;
if (GetUserNameW( (LPWSTR)name, &size ))
{
cout << "Hello, " << name << "!\n";
}
else
{
cout << "Hello, unnamed person!\n";
}
}
return 0;
}
Can anybody tell me how to convert this to a wstring?
Thank you.