Examples Delphi

How to get the current user's login name.
function UserName : String;
var
Size : DWord;
Name : PChar;
begin
Name := StrAlloc(256);
Size := 255;
if GetUsername(Name,Size) then
Result := String(Name)
else
Result := '';
StrDispose(Name);
end;