Here is a simple Delphi function that returns the user name for the currently logged-in user. For additional Delphi code for the Windows operating system, see Useful Delphi Code for the Windows Operating System.
function LoggedInUserName: String; var Size: DWORD; Name: Array[0..255] of char; begin LoggedInUserName := ''; Size := 0;