Unix to Windows Porting Dictionary for HPC |
|
|
RSS
LinksFunction List
|
Table of Contents header file: Windows.h BOOL WINAPI GetUserName(__out LPTSTR lpBuffer, __inout LPDWORD lpnSize); The GetUserName function will provide the same information as the Unix getlogin() function, but with a slightly different format. Instead of returning the unsername, GetUserName stores it in the parameter lpBuffer. It also requires a second parameter, lpnSize, that specifies the size of lpBuffer. For complete details, see the MSDN article.
#include <Winsock2.h>
char* buffer[256];
if (GetUserName(buffer, 256) == 0)
printf("The local username is %s.", buffer);
else
printf("GetUserName error.");
|
|
|
|