How can I use in MFC programming GetUserName method which is win32 command. I don't have had any luck getting username into CString.
-Teemu
Printable View
How can I use in MFC programming GetUserName method which is win32 command. I don't have had any luck getting username into CString.
-Teemu
Hi Teemu,
I just finish headache implementing this **** thing. GetUserName accept two parameters.Following Code will work for you:
char userName[256];
DWORD nameLength;
.........
nameLength = sizeof(userName);
if (GetUserName(userName, nameLength) != 0) {
// You have user name in buffer userName, Now you can move this value in CString variable.
Good luck.
--Sumit