Re:One instance of APP only
:Don Schoeman <dpds...@mweb.co.za> schrieb in im Newsbeitrag: 3898986...@news1.mweb.co.za...
: In the TI documents provided by Borland/Inprise, an example is given on how
: to get an application to stop a second instance of itself being executed.
:
: This example doesn't seem to work in Delphi 4. Is there any other way of
: doing this. (It must work on NT also).
:
: Thanks!
:
:
I don't know what Inprise provided there but here's an example of this NG using an OS object called "Mutex":
uses
{...}
Windows;
var
hMutex:THandle;
begin
hMutex:=CreateMutex(nil, false, 'MyMutex');
if WaitForSingleObject(hMutex,0)<>wait_TimeOut then begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
{...}
Application.Run;
end;
ReleaseMutex(hMutex);
end.
Hth,
Matthias.