Autor Beitrag
gispos
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 94

WIN 7
XE10, D2007
BeitragVerfasst: Sa 08.11.08 14:20 
Hallo,
suche Methode den PC in den Standby oder Ruhemodus zu versetzen.
Finde nur Lösungen zum herunterfahren oder reboot.

Kann mir jemand helfen?
Gruß gispos


Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Sa 08.11.2008 um 13:27
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 08.11.08 14:27 

_________________
We are, we were and will not be.
j.klugmann
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.11.08 14:28 
Die Lösung heißt: SuFo
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.11.08 14:30 
Immer wieder toll, diese Crossposts :?
gispos Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 94

WIN 7
XE10, D2007
BeitragVerfasst: Sa 08.11.08 15:23 
Immer wieder Toll diese Antworten. :shock:

Habe 30 Minuten Themen über Windows-Suspend gesucht und gelesen, war aber nix brauchbares dabei.
Hätte sonst hier keine Anfrage gestellt!
Und wenn ich mich bei der Benutzung der SuFo dumm angestellt habe,
dann bitte ich dies, meine Herren, mir zu verzeihen.

Edit: @Gausi > Danke für den Link!

Gruß gispos


Zuletzt bearbeitet von gispos am Sa 08.11.08 15:39, insgesamt 2-mal bearbeitet
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.11.08 15:27 
Crossposts sind ja nicht generell verboten, aber sie sollten als solche kenntlich gemacht werden. Sonst ärgert man sich als Antwortender, dass die Lösung bereits gezeigt wurde, man selbst das aber nicht wusste.
j.klugmann
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.11.08 15:30 
Ich poste mal den Code den ich per SuFu gefunden habe:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
uses
  Windows;

type
  TShutdownWindowsType = (swtShutdown, swtShutdownPowerOff, swtRestart, swtLogoff);

function ShutdownWindows (aType: TShutdownWindowsType): Boolean;

{...}

function ShutdownWindows (aType: TShutdownWindowsType): Boolean;

const
  cSE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
  cFlagValue: Array [TShutdownWindowsType] Of UINT = (
      EWX_SHUTDOWN, EWX_SHUTDOWN or EWX_POWEROFF, EWX_REBOOT, EWX_LOGOFF
    );

var
  OSVersionInfo: TOSVersionInfo;
  hToken: THandle;
  hProcess: THandle;
  TokenPriv: TTokenPrivileges;
  ReturnLength: DWORD;

begin
  Result := False;

  // Die Windowsversion holen
  OSVersionInfo.dwOSVersionInfoSize := SizeOf (OSVersionInfo);
  if not GetVersionEx (OSVersionInfo) then
    Exit;

  // Prüfen ob Windows NT
  if OSVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then
    begin
      hProcess := GetCurrentProcess;
      if not OpenProcessToken (hProcess, TOKEN_ADJUST_PRIVILEGES, hToken) then
        Exit;

      if not LookupPrivilegeValue (nil, cSE_SHUTDOWN_NAME, TokenPriv.Privileges[0].Luid) then
        Exit;

      TokenPriv.PrivilegeCount := 1;
      TokenPriv.Privileges [0].Attributes := SE_PRIVILEGE_ENABLED;

      if not AdjustTokenPrivileges (
          hToken, False, TokenPriv, 0,
          PTokenPrivileges (nil)^, ReturnLength
        )
      then
        Exit;

      CloseHandle (hToken);
    end;

  ShutdownWindows := ExitWindowsEx (cFlagValue [aType], $FFFFFFFF);
end



So. :wink:
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 08.11.08 15:33 
Es ging hier um den Ruhezustand, nicht um Shutdown ;)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 08.11.08 15:35 
Ich würde sagen: Da ist jetzt eine kleine Entschuldigung angebracht. ;-)

_________________
We are, we were and will not be.