Wednesday, December 13, 2017

DELPHI - How get username of connected user

function My_GetUserName : string;
var
  buffer : array[ 0..255 ] of char;
  i      : dword;
begin
  fillChar( buffer, sizeof( buffer ), #0 );
  i := sizeof( buffer );
  getUserName( @buffer, i );
  result := strPas( buffer );
end;
When you call it:
ShowMessage( My_GetUserName );
Output could be:

No comments:

Post a Comment