On Windows 7 to retrieve the name of a logged on user I can do this:
LPTSTR pUserName = NULL;
DWORD dwcbSzUserName = 0;
//'dwSessID' = user session ID
if(WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessID, WTSUserName, &pUserName, &dwcbSzUserName))
{
//Got user name in 'pUserName'
}
if(pUserName)
WTSFreeMemory(pUserName);
But on Windows 8 it returns some abbreviated name, for instance, "john_000" when the actual user's name is "John A. Doe".
So what is the way to retrieve the name of the logged on user (and possibly their email) on Windows 8 with C++ using WinAPIs as it's shown at log-on screen?
You could try NetUserGetInfo with USER_INFO_23 to get full name.
Something basically like: