вот пример:
http://www.codersource.net/win32_user_name.html
Цитата:
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( LPTSTR lpBuffer, LPDWORD nSize);