Get user name of currently logged in user
This simple function will return name of currently logged in user.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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; |