Autor Beitrag
lord tanas
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Do 21.07.05 16:50 
Hi leute ich habe (mal wieder) ein kleines Problem,
ich habe mir einige shutdown tool aus dem net geladen und festgestellt, dass alle nicht so meinen erwartungen entsprechen, drum will ich mal selber hand anlegen. Jetzt stellt sich aber die Frage:
Wie schaltet man per Prog den Pc aus oder lässt ihn rebooten oder am aller aller besten wie fährt man ihn in den ruhezustands-Modus??
kann mir jemand helfen...

Thx schonmal im vorraus
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 21.07.05 16:53 
Die Forensuche kann dir helfen. :roll:
sango
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 236

WinXP Home
Delphi 2005 Pro
BeitragVerfasst: Do 21.07.05 16:56 

_________________
Never read the Off-Topic
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 23.07.05 15:45 
Nimm das:
Einloggen, um Attachments anzusehen!
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 23.07.05 15:52 
Dein Link funzt nit ;) (der Download).

@lord tanas: Lade dir am besten den EasyHelper mal runter.

Er sagt folgendes dazu aus:

Zitat:
Folgender Code kann sowohl Windows 95 / 98 / Me als auch NT / 2000 / XP herunterfahren.
Bei der zweitgenannten Gruppe müssen zuerst die für einen Shutdown notwendigen Privilegien gesetzt werden.
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:
function ExWindows(const AFlag: Word): Boolean;
var
  vi     : TOSVersionInfo;
  hToken : THandle;
  tp     : TTokenPrivileges;
  h      : DWord;
begin
  result:= false;

  vi.dwOSVersionInfoSize:=SizeOf(vi);

  if GetVersionEx(vi) then
  begin
    if vi.dwPlatformId = VER_PLATFORM_WIN32_NT then
    begin
      // Windows NT
      // Achtung bei Delphi 2 muß @hToken stehen ...
      if OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,hToken) then
      begin
        LookupPrivilegeValue(nil,'SeShutdownPrivilege',tp.Privileges[0].Luid);
        tp.PrivilegeCount := 1;
        tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
        h := 0;
        AdjustTokenPrivileges(hToken,False,tp,0,PTokenPrivileges(nil)^, h);
        CloseHandle(hToken);
        result := ExitWindowsEx(Aflag, 0);
      end;
    end
    else
    begin // Windows 95
      Result := ExitWindowsEx(Aflag, 0);
    end;
  end;
end;

Mögliche Werte für den Parameter Flag:


EWX_Logoff - Loggt den User aus

EWX_Poweroff - Unterstützt der Rechner, dieses Feature, wird der Computer nach dem Herrunterfahren ausgeschaltet.

EWX_Reboot - Computer wird neu gestartet

EWX_Shutdown - Der Computer wird normal herruntergefahren

Die o.g. Parameter lassen sich zusätzlich über OR mit EWX_FORCE oder ab Windows2000/XP mit EWX_FORCEIFHUNG verknüpfen. EWX_FORCE fährt den Computer direkt herrunter. Dies kann u.U. zu Datenverlusten führen. EWX_FORCEIFHUNG gibt anderen Programmen zwar die Chance sich zu schließen, fährt den Rechner allerdings trotzdem herrunter, wenn sie sich aufgehängt haben.

Für weitere Informationen lesen Sie bitte in der PSDk unter dem Stichwort "ExitWindowsEx".
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Sa 23.07.05 16:33 
user profile iconlord tanas hat folgendes geschrieben:
...am aller aller besten wie fährt man ihn in den ruhezustands-Modus??

siehe neuestem eintrag auf meiner hp (hibernate.zip)

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 24.07.05 10:17 
Zitat:
Dein Link funzt nit ;) (der Download).

Geht bei mir einwandfrei (XP Home ohne SP's).
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: So 24.07.05 12:14 
Bei mir nicht (FF 1.0.4 und IE 6.0).
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 24.07.05 12:20 
Achso, du meinst das runterladen. Stimmt, geht net.
ausblenden Delphi-Quelltext
1:
2:
type 
  TShutdownWindowsType = (swtShutdown, swtShutdownPowerOff, swtRestart, swtLogoff);

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:
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);

ausblenden Delphi-Quelltext
1:
ShutdownWindows(swtShutDownOff {oder swtShutDown oder swtRestart});