How can I get the current logon user name(including the domain name)? Any API?
Create a new form with one button and one label. Do not rename either.
In the 'on-click' event for the button type the following code so the whole event looks like this.
//----------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
DWORD dwSize = MAX_PATH+1;
char szBuf[MAX_PATH+1];
szBuf[0] = '\0';
GetUserName(szBuf, &dwSize);
Label1->Caption = szBuf;
}
//----------------------------------------------------------
When you click the button, the PC's username appears in the label. Viola!