Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Task überprüfen (https://www.delphipraxis.net/71660-task-ueberpruefen.html)

Pump3r 19. Jun 2006 08:52


Task überprüfen
 
Hi, kann mir wer sagen, wie ich überprüfen kann, ob zb: Opera.exe läuft?



Danke, Gruß Pump :angel:

ascotlx 19. Jun 2006 09:05

Re: Task überprüfen
 
Moin Pump,

ich prüfe auf diese Art, ob mein Programm schon läuft ....

Delphi-Quellcode:
// ist das Programm schon gestartet ??
initialization
  H := CreateMutex(nil, True, 'Opera.exe');
  if GetLastError = ERROR_ALREADY_EXISTS then
    begin
      MessageDlg('Opera'
       +#13+#13+'das Programm ist bereits aktiv.',
       mtInformation, [mbOk], 0);
      Halt;
    end;

finalization
  if H <> 0 then
    begin
      CloseHandle(H);
    end;
HTH

Gruß
ascotlx

Pump3r 19. Jun 2006 09:05

Re: Task überprüfen
 
Delphi-Quellcode:
unit test;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ShellAPI;

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation
var
H : THandle;

{$R *.dfm}

initialization
  H := CreateMutex(nil, True, 'Opera.exe');
  if GetLastError = ERROR_ALREADY_EXISTS then
    begin
      MessageDlg('Opera'
       +#13+#13+'das Programm ist bereits aktiv.',
       mtInformation, [mbOk], 0);
      Halt;
    end;

finalization
  if H <> 0 then
    begin
      CloseHandle(H);
  end;

end.

dat will nicht so wie ich will :(

Pump3r 19. Jun 2006 10:14

Re: Task überprüfen
 
naja ok es funktioniert jetzt.
nur mein problem ist:

wenn ich mein testprogramm starte, und es nochmal starte, dann kommt eben der message dialog und das programm beendet.

ich wollte aber beim start meines testprogramms überprüfen ob die exe vom Opera Broweser (Opera.exe) gestartet ist.
also nicht überprüfen ob die testexe schon läuft.


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz