The GetUserName function retrieves the user name of the current thread. This is the name of the user currently logged onto the system.
BOOL GetUserName( LPSTR lpBuffer, DWORD * nSize )
If the function succeeds, the return value is a nonzero value, and the variable pointed to by nSize contains the number of chars copied to the buffer specified by lpBuffer, including the terminating null character.
If the function fails, the return value is zero.
EX1
int GetUserName_ex1() { char szUserName[MAX_PATH]; DWORD dwSize = MAX_PATH; if( GetUserName(szUserName, &dwSize) ) printf("User Name is %s\n", szUserName); else printf("Error calling GetUserName\n"); return 1; }
GetComputerName
origin.h