AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Passwort automatisch eingeben

Ein Thema von lukdelphias · begonnen am 10. Aug 2020 · letzter Beitrag vom 17. Aug 2020
 
Benutzerbild von Moombas
Moombas

Registriert seit: 22. Mär 2017
Ort: bei Flensburg
525 Beiträge
 
FreePascal / Lazarus
 
#18

AW: Passwort automatisch eingeben

  Alt 11. Aug 2020, 07:19
Also ich mache da aktuell so (allerdings in Lazarus):

Delphi-Quellcode:
//Oberhalb des "implementation" Bereichs
function CreateProcessWithLogonW(lpUsername, lpDomain, lpPassword: LPWSTR; dwLogonFlags: dword; lpApplicationName,
  lpCommandLine: LPWSTR; dwCreationFlags: dword; lpEnvironment: pointer; lpCurrentDirectory: LPWSTR; lpStartupInfo:
  PStartUpInfoW; lpProcessInfo: PProcessInformation): boolean; stdcall; external 'advapi32.dll';
Delphi-Quellcode:
//Im "implementatrion" Bereich
//Prozess als bestimmten Benutzer starten
function CreateProcessAsLogon(const User, PW, Application, param, CmdLine: WideString): DWORD;
var
  ws : WideString;
  si : TStartupInfoW;
  pif : TProcessInformation;
begin
  ZeroMemory(@si, sizeof(si));
  si.cb := sizeof(si);
  si.dwFlags := STARTF_USESHOWWINDOW;
  si.wShowWindow := 1;

  if CmdLine = 'then
  begin
    ws := Application;
  end else
  begin
    ws := Application + ' "' + CmdLine + '"';
  end;

  SetLastError(0);
  SI.cb := SizeOf(TStartupInfo);
  if CreateProcessWithLogonW(PWideChar(User), nil, PWideChar(PW), 0, nil, PWideChar(ws), CREATE_DEFAULT_ERROR_MODE, nil, PWideChar(param), @si, @pif) then
  begin
    sleep(500);
    if PIf.dwProcessId > 0 then
    begin
      AppPID := PIf.dwProcessId;
      CloseHandle(PIf.hProcess);
      CloseHandle(PIf.hThread);
    end;
  end;
  Result := GetLastError;
end;
Der Weg ist das Ziel aber man sollte auf dem Weg niemals das Ziel aus den Augen verlieren.

Geändert von Moombas (11. Aug 2020 um 07:24 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:39 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz