Hallo zusammen,<br>
mir stellt sich folgendes Problem. <br>
Mein Programm hat registrierte Dateien die beim öffnen im z.B. Explorer das Programm starten und geöffnet werden (shell\open\command). Im onCreate Ereigniss der MainForm wird dann über Params die jeweilige Datei geöffnet. Jetzt habe ich aber den mehrfach Programm start verhindert ....<br>
<pre><b>
unit only_one;
interface
implementation
uses forms, windows;
var mutex : THandle;
h : HWnd;
initialization
mutex := CreateMutex(nil,true,'AcoboMutex');
if getLastError = ERROR_ALREADY_EXISTS then begin
h := 0;
repeat
h := FindWindowEx(0,h,'TApplication',PChar('Admin CookBook'))
until h <> application.handle;
if h <> 0 then begin
//hier die Datei zu öffnen quitiert Windows mit vielen Fehlern ;-(
Windows.ShowWindow(h, SW_ShowNormal);
windows.SetForegroundWindow(h);
end;
halt;
end;
finalization
ReleaseMutex(mutex);
end.
</b></pre><br>
..... und bekomme es nicht hin das passende Ereigniss zu finden um die Registrierte Datei zu öffnen.<br>
Habt Ihr ne Idee ??
mir stellt sich folgendes Problem. <br>
Mein Programm hat registrierte Dateien die beim öffnen im z.B. Explorer das Programm starten und geöffnet werden (shell\open\command). Im onCreate Ereigniss der MainForm wird dann über Params die jeweilige Datei geöffnet. Jetzt habe ich aber den mehrfach Programm start verhindert ....<br>
<pre><b>
unit only_one;
interface
implementation
uses forms, windows;
var mutex : THandle;
h : HWnd;
initialization
mutex := CreateMutex(nil,true,'AcoboMutex');
if getLastError = ERROR_ALREADY_EXISTS then begin
h := 0;
repeat
h := FindWindowEx(0,h,'TApplication',PChar('Admin CookBook'))
until h <> application.handle;
if h <> 0 then begin
//hier die Datei zu öffnen quitiert Windows mit vielen Fehlern ;-(
Windows.ShowWindow(h, SW_ShowNormal);
windows.SetForegroundWindow(h);
end;
halt;
end;
finalization
ReleaseMutex(mutex);
end.
</b></pre><br>
..... und bekomme es nicht hin das passende Ereigniss zu finden um die Registrierte Datei zu öffnen.<br>
Habt Ihr ne Idee ??
Comment