Einzelnen Beitrag anzeigen

Benutzerbild von xZise
xZise

Registriert seit: 3. Mär 2006
Ort: Waldbronn
4.303 Beiträge
 
Delphi 2009 Professional
 
#26

Re: [Win2000] - Abmelden vom Dienst

  Alt 30. Mär 2009, 16:46
Hallo Dezipaitor,

Zitat:
An Exception of type EJwsclProcessIdNotAvailable was raised.
(Data was given by programmer and can vary from actual source.)
Source method....: Create
Source class.....: TJwImpersonation
Source file......: JwsclImpersonation.pas
Source line......: 0
GetLastError.....: 1400 ($578)
GetLastErrorMsg..: Ungültiges Fensterhandle

Message : The process "Progman1" (Id: 0x0) could not be found.
mit folgenden Code:
Delphi-Quellcode:
function ImpersonateAndExecute(const Flag : DWORD) : Boolean;
var
  Imp : IJwImpersonation;
  PrivScope : IJwPrivilegeScope;
begin
  Result := true;
  try
    //raises EJwsclProcessIdNotAvailable
    //EJwsclWinCallFailedException
    Imp := JwImpersonateLoggedOnUser;

    if TJwWindowsVersion.IsWindows2000(true) then
    begin
      //raises EJwsclPrivilegeException
      PrivScope := JwGetPrivilegeScope([SE_SHUTDOWN_NAME]);

      if not ExitWindowsEx(Flag, 0) then
        RaiseLastOSError;
    end else
      AddToLog('Not W2k+');
  except
    on e: Exception do
    begin
      AddToLog(e.Message);
// on e : EJwsclProcessIdNotAvailable do
      Result := false;
// on e : EJwsclWinCallFailedException do
      Result := false;
    end;
  end;
end;
MfG
xZise
Fabian
Eigentlich hat MS Windows ab Vista den Hang zur Selbstzerstörung abgewöhnt – mkinzler
  Mit Zitat antworten Zitat