Use GetUserName for solving of this problem. For example:
procedure TForm1.Button1Click(Sender: TObject); var StrUserName: PChar; Size: DWord; begin Size:=250; GetMem(StrUserName, Size); GetUserName(StrUserName, Size); Label1.Caption:=StrPas(StrUserName); FreeMem(StrUserName); end;