schardosin
asked on
Know user logged in the Windows
Hi,
How can I know the user who is logged in the Windows with the Delphi ???
Thank´s!!!
Rafael Schardosin
Porto Alegre - Brazil
How can I know the user who is logged in the Windows with the Delphi ???
Thank´s!!!
Rafael Schardosin
Porto Alegre - Brazil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That was easy, especially since this question has been answered many times before... ;-)
Function LoggedName : string;
var
sizeOfuser : cardinal;
user : array[0..255] of char;
begin
sizeOfuser := sizeof(user);
IF getusername(user,sizeOfuse r) = true then
Begin
Result := string(user);
End
Else
Result := 'NO USER';
end; { LoggedName }
now you just need to call the function
ex:
Edit1.Text := LoggedName;
tested on winxp
var
sizeOfuser : cardinal;
user : array[0..255] of char;
begin
sizeOfuser := sizeof(user);
IF getusername(user,sizeOfuse
Begin
Result := string(user);
End
Else
Result := 'NO USER';
end; { LoggedName }
now you just need to call the function
ex:
Edit1.Text := LoggedName;
tested on winxp