// Visual C++ 5.0: cl getusername.cpp advapi32.lib
//
// This sample program is hereby placed in the public domain.
#include
#include
int main()
{
char acUserName[100];
DWORD nUserName = sizeof(acUserName);
if (GetUserName(acUserName, &nUserName)) {
cout << "Bekabe | Username komputer: " << acUserName << "." << endl;
}
else {
cerr << "Bekabe | Gagal melihat username, error pada: " <<
GetLastError() << "." << endl;
}
return 0;
}