How to display the current user name.
By: Kendall Sullivan
Abstract: Code example to display the current user name.
|
QUESTION:
How can I get the name of the user currently logged onto the system.
ANSWER:
The code sample below displays the current user's name.
function CurrentUserName:String;
var
u: array[0..127] of Char;
sz:DWord;
begin
sz:=SizeOf(u);
GetUserName(u,sz);
Result:=u;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(CurrentUsername);
end;
|
Server Response from: BDN9A