Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 04.08.05 15:12 
Kann man ein Programm in den Vordergrund bringen, wovon nur der Mutex bekannt ist? Ich will also den Mutex-Inhaber in den Vordergrund bringen. Im Forum findet man ja nix dazu. Hier mein bisheriger Quelltext:

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:
program Project1;

uses
  Forms, Windows,
  Unit1 in 'Unit1.pas' {Form1},
  Fortschritt_Unit in 'Fortschritt_Unit.pas' {Form2},
  Einstellungen_Unit in 'Einstellungen_Unit.pas' {Form3};

{$R *.res}

var mHandle: THandle;

begin
  mHandle:=CreateMutex(nil, True, PChar('MP3-Tag-Editor'));
  if GetLastError=ERROR_ALREADY_EXISTS then
   begin
    Application.MessageBox('Die Anwendung läuft bereits und kann nicht noch einmal gestartet werden.''MP3-Tag-Editor'16);
    Halt
   end
  else
   begin
    Application.Initialize;
    Application.Title:='MP3-Tag-Editor';
    Application.CreateForm(TForm1, Form1);
    Application.CreateForm(TForm2, Form2);
    Application.CreateForm(TForm3, Form3);
    Application.Run
   end;
  if mHandle<>0 then
   begin
    CloseHandle(mHandle);
   end;
end.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Do 04.08.05 15:47 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var mHandle: THandle;

begin
  mHandle:=CreateMutex(nil, True, PChar('MP3-Tag-Editor'));
  if GetLastError=ERROR_ALREADY_EXISTS then
  begin
    SetForeGroundWindow(mHandle);
    { Application.MessageBox('Die Anwendung läuft bereits und kann nicht noch einmal gestartet werden.', 'MP3-Tag-Editor', 16); }
    Halt;
  end


CreateMutex liefert bei ERROR_ALREADY_EXISTS das handle auf das bereits existierende objekt zurück.

MfG
Nicolai

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 04.08.05 16:00 
Das funktioniet irgendwie nicht.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Do 04.08.05 16:12 
hmm, dann probier mal, das Fensterhandel deiner Anwendung über FindWindow('FensterTitelName', nil) zu finden und dann ne Windows Message (SC_RESTORE oder so) an das Fenster zu schicken, danach auf das Fensterhandel den SetForegroundWindow.

Hab das schon lange nciht mehr gemacht, deshalb kann's sein, da fehlt noch was. google am besten mal nach Suche bei Google DELPHI MUTEX

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 04.08.05 16:14 
ICh wollte es eigentlich auf diese Variante machen, da es ja auch andere Programme gibt, die den gleichen Fenstertitel haben.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Do 04.08.05 16:28 
sorry sonst wüsste ich jetzt keine andere alternative

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean