Know the sesion login name in NT  

Send By: Salvador Verdú
Web : N.A.
Email: 3045@larural.es
Date: 03/02/00

Tip accessed 447 times

 


  • Add 'Registry' in the uses of your form
  • Put a TLabel (Label1) and a TButton (Button1)
  • And put this code in the OnClick of Button1:

     procedure TForm1.Button1Click(Sender: TObject);
     var
        Registro: TRegistry;
     begin
        Registro := TRegistry.Create;
        Registro.RootKey := HKEY_LOCAL_MACHINE;
        Registro.OpenKey( 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon', False );
        Label1.Caption := Registro.ReadString( 'DefaultUserName' );
        Registro.CloseKey;
        Registro.Destroy;
     end;