24 Apr

Get user name of currently logged in user

This simple function will return name of currently logged in user.

function UserName: String;
var User: PChar;
    i: DWord;
begin
  i := 1024;
  user := StrAlloc(Succ(i));
  if GetUserName(User, i) then Result := StrPas(User)
                          else Result := 'unknown';
end;
  • Digg
  • del.icio.us
  • Facebook
  • Twitter
  • Technorati
  • Google Bookmarks
  • Live
  • LinkedIn
  • MySpace

Leave a Reply

You must be logged in to post a comment.