Главная страница | назад





Article #26731: How 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;

Last Modified: 02-FEB-01