Einzelnen Beitrag anzeigen

Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.685 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Passwort automatisch eingeben

  Alt 10. Aug 2020, 13:09
Meinst Du so etwas?

Delphi-Quellcode:
procedure RunAsExec(hWnd: HWND; aFile: string; aParameters: string);
var
  SEI: TShellExecuteInfo;
begin
  FillChar(SEI, SizeOf(SEI), 0);
  SEI.cbSize := sizeof(SEI);
  SEI.Wnd := hWnd;
  SEI.fMask := SEE_MASK_NOCLOSEPROCESS;
  SEI.lpVerb := 'runas';
  SEI.lpFile := PChar(aFile);
  SEI.lpParameters := PChar(aParameters);
  SEI.nShow := SW_SHOWNORMAL;
  if not ShellExecuteEx(@SEI) then
    RaiseLastOSError;
end;
Beispiel-Aufruf:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  DateiName: string;
  Parameter: string;
begin
  DateiName := 'Programm.exe';
  Parameter := ' ' + 'Benutzername' + ' ' + 'Passwort';
  RunAsExec(Application.Handle, DateiName, Parameter);
end;
Gruß vom KodeZwerg
  Mit Zitat antworten Zitat