Autor Beitrag
Erzengel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Mi 28.01.04 09:00 
Hallo,

kennt einer den Quellcode um Windows runterzufahren???
Möchte das in einem Button einbauen.

Wäre nett wenn ihr was habt.

Moderiert von user profile iconPeter Lustig: Topic Verschoben

_________________
Ein Kreis ist ein rundes Quadrat


Zuletzt bearbeitet von Erzengel am Mi 28.01.04 13:39, insgesamt 1-mal bearbeitet
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 28.01.04 09:34 
1. Suchfunktion.
2. FAQs.
3. Glaube nicht, du bist der Erste, der das hier fragt.
4. @Mods: Zumachen.

:evil:
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 28.01.04 11:07 
Titel: Rechtschreibung!!!
Hallo!

Siehe oben!

Und wenn Du bei Deiner Suche herunterfahren mit einem r schreibst findest Du auch was!!

Ciao,
S.J.
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Mi 28.01.04 15:43 
Brauch ich eine Komponete wenn ja wo finde ich diese.
Habe jetzt alle durchgeguckt

_________________
Ein Kreis ist ein rundes Quadrat
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 28.01.04 15:59 
Erzengel hat folgendes geschrieben:

Habe jetzt alle durchgeguckt

wie du hier suchst, mußt du mir mal erklären

FAQ: www.delphi-forum.de/viewtopic.php?t=8272

oder Suche in: Delphi-Forum, Delphi-Library WINDOWS HERUNTERFAHREN

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Mi 28.01.04 16:01 
Vielleicht nützt dir ja das was:
www.swissdelphicente.../showcode.php?id=168

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Mi 28.01.04 16:09 
Ich meine nicht hier gesucht weil mit den kann ich nichts anfangen.
Ich suche Sie in meinem Delphi.

Vielleicht weiß ja einer wo die zufinden ist.(Kateikarte)

Danke für den Link aber ich habe hier nur begrenzten internetzugang. :evil:

_________________
Ein Kreis ist ein rundes Quadrat
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 28.01.04 16:24 
Wo liegt das Problem? Keldorn hat Dir bereits einen Link genannt, den Du auch sicherlich verwenden kannst, weil er forenintern ist.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 28.01.04 16:41 
das ist keine komponenten sondern ein code befehl. falls du das meinst !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Do 29.01.04 08:23 
Ahh sag das doch.
Genau das wollte ich wissen

_________________
Ein Kreis ist ein rundes Quadrat
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Do 29.01.04 14:36 
Ok aber ich bin ja noch anfänger. Habe das so zusamen gebastelt.
Kann mir wer helfen den Quelltext zu berichtigen???

Bitte nicht böse sein wenn ich nicht gleich blicke :oops:

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:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type  TShutdownWindowsType = (swtShutdown, swtShutdownPowerOff, swtRestart, swtLogoff);
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);



  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}




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;




procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsEx (EWX_SHUTDOWN or EWX_POWEROFF, $FFFFFFFF);

end;

end.

_________________
Ein Kreis ist ein rundes Quadrat
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 29.01.04 15:08 
was bringt er denn für ne fehlermeldung ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Do 29.01.04 15:40 
Gar keine. Es passiert einfach nichts.
Ich drücke den button und ......... nichts passiert.

_________________
Ein Kreis ist ein rundes Quadrat
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Do 29.01.04 16:26 
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:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type  TShutdownWindowsType = (swtShutdown, swtShutdownPowerOff, swtRestart, swtLogoff);
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);



  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}




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

  result := ExitWindowsEx (cFlagValue [aType], $FFFFFFFF); //hier war Fehler 1, kein result ! bzw. bei dir immer false
end;




procedure TForm1.Button1Click(Sender: TObject);
begin
ShutdownWindows (EWX_SHUTDOWN or EWX_POWEROFF, $FFFFFFFF); // hier hast du nicht deine Funktion sondern ExitWindowEx aufgerufen und ohne vorher des privileg zu besitzen wirds nicht funzen

end;

end.

_________________
mfg
Tana´Ri
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Fr 30.01.04 11:43 
Sorry aber jetzt krieg ich die Fehlermeldung

[Fehler] Unit1.pas(86): Inkompatible Typen: 'TShutdownWindowsType' und 'Integer'

Steh vor der Wand und komme nicht weiter.

_________________
Ein Kreis ist ein rundes Quadrat
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 30.01.04 12:35 
Ist schon schwer alles per Copy and Paste zu übernehmen oder?

www.delphi-forum.de/viewtopic.php?t=8272
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Fr 30.01.04 12:48 
hatte das vorher noch nie gesehen, ist aber das gleiche
-> ob ich nun result das Funktionsergebnis zuweise oder den Funktionsname anstatt result hinschreibe.

der button1click sollte doch deine Shutdown Fkt aufrufen oder ? was steht in line 86 ?

TShutdownWindowsType - Error

ExitWindowsEx (cFlagValue [aType], $FFFFFFFF);

hier wird ein Integer (ohne Vorzeichen) benötigt !

-> die TShutdownWindowsType mengenelemente sollte Konstanten sein die den jeweiligen Wert repräsentieren

siehe Windows.pas

EWX_LOGOFF = 0;

EWX_SHUTDOWN = 1;

EWX_REBOOT = 2;

EWX_FORCE = 4;

EWX_POWEROFF = 8;

EWX_FORCEIFHUNG = $10;

_________________
mfg
Tana´Ri
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 30.01.04 12:59 
nil
Tana´Ri
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 230



BeitragVerfasst: Fr 30.01.04 13:05 
Wat du wolle ?! :evil:

ok zurück genommen 8)

_________________
mfg
Tana´Ri
Erzengel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 99

Win 2000, WinXP
Delphi 5 Enterprise
BeitragVerfasst: Fr 30.01.04 13:17 
Heute is net mein Tag :evil:

_________________
Ein Kreis ist ein rundes Quadrat