Autor Beitrag
chrisbie
Hält's aus hier
Beiträge: 4

win XP

BeitragVerfasst: So 02.03.08 13:53 
ich will für ein programm den windwosshutdown registrieren und protkollieren. allerdings klappt das leider nicht so, wie ich mir das vorstelle.

nach stöbern im forum bin ich auf folgende lösung gestoßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure Tform1.WMPowerBrodacast(var m:TMessage);
 begin
  if (Msg.WParam = PBT_APMSUSPEND) then [b][i]//hier eine Fehlermeldung:[Fehler] Unit1.pas(114): Objekt oder Klassentyp erforderlich[/i][/b]
   begin
    assignFile(logfile, 'zeit.log');
    append (logfile);
    write (logfile, datetostr(date) +' um '+timetostr(now)+' Comuter Ausgeschaltet,');
    writeln (logfile, ' laufzeit: '+ timetostr(laufzeit)+' Stunden');
    writeln (logfile);
    closefile(logfile);
   end;
end;


habe ich was vergessen?
bin ein relativer delphi leie.

hoffe auf hilfe, danke

Moderiert von user profile iconNarses: Fragestatus von gelöst auf offen gesetzt.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: So 02.03.08 14:23 
wie wäre es mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure Tform1.WMPowerBroadcast(var m:TMessage); // Broad, net Broda, Borda oder Borat ^^
 begin
  if (Msg.WParam = PBT_APMSUSPEND) then // das was da stand war schmu
   begin
    assignFile(logfile, 'zeit.log');
    append (logfile);
    write (logfile, datetostr(date) +' um '+timetostr(now)+' Comuter Ausgeschaltet,');
    writeln (logfile, ' laufzeit: '+ timetostr(laufzeit)+' Stunden');
    writeln (logfile);
    closefile(logfile);
   end;
end;


mfg
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: So 02.03.08 14:36 
Ich glaube, du hast die ganz falsche Message. Beim Beenden gibts WM_QUERYENDSESSION und WM_ENDSESSION. Darauf musst du reagieren. Die Message WM_POWERBROADCAST gibts beim Schlafengehen/aufwachen, also Ruhemodus etc.

_________________
We are, we were and will not be.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 02.03.08 15:08 
Moin!

user profile iconGausi hat folgendes geschrieben:
Beim Beenden gibts WM_QUERYENDSESSION und WM_ENDSESSION.
Hm :gruebel: die gibt´s doch aber beim An-/Abmelden, das hat ja nix mit dem Runterfahren zu tun. :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
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: So 02.03.08 15:19 
Doch. ;-) Vor dem Runterfahren wird abgemeldet.

Im lParam der Message steht dann drin, was genau passiert. Bei lParam=0 wird das System wird runtergefahren (oder neu gestartet), beu lParam=ENDSESSION_LOGOFF wird nur abgemeldet. (MSDN-Link).

_________________
We are, we were and will not be.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 02.03.08 15:23 
Moin!

user profile iconGausi hat folgendes geschrieben:
Bei lParam=0 wird das System wird runtergefahren
Jau, stimmt ja. ;)

Allerdings kriegen nur Toplevel-Windows die Nachricht. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
chrisbie Threadstarter
Hält's aus hier
Beiträge: 4

win XP

BeitragVerfasst: Do 06.03.08 19:01 
sorry aber warscheinlich bin ich einfach nur zu blöd für so was.
ich bekomme das net hin. noch mal ganz langsam für dumme.
ich bin jetzt so weit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
type
  TForm1 = class(TForm)
   
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer1Timer(Sender: TObject);
    procedure WMPowerBroadcast(var msg:TMessage);

// weiterer Programm teil

procedure Tform1.WMPowerBroadcast(var msg:TMessage);
 begin
  if Msg.WParam = PBT_APMSUSPEND then  //(immer noch) [Fehler] Unit1.pas(114): Undefinierter Bezeichner: 'PBT_APMSUSPEND'
   begin
    assignFile(logfile, 'zeit.log');
    append (logfile);
    write (logfile, datetostr(date) +' um '+timetostr(now)+' Comuter Ausgeschaltet,');
    writeln (logfile, ' laufzeit: '+ timetostr(laufzeit)+' Stunden');
    writeln (logfile);
    closefile(logfile);
   end;
end;


habe ich irgendwo was vergessen?
muss ich irgendwo noch was definieren?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 06.03.08 20:46 
Moin!

user profile iconchrisbie hat folgendes geschrieben:
habe ich irgendwo was vergessen?
Ähm, ja? :? Zum Beispiel die letzten Beiträge zu lesen, insbesondere den von user profile iconGausi? :nixweiss:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.