dra.:.god - 2002-05-27

Logged In: YES
user_id=553457

Here's the code for that:

MainFormUnit:

var
mHandle: THandle; { dragod 020527 }

procedure TMainForm.FormCreate(Sender: TObject);
var { dra.:.god 020527 }
Sem: THandle; { dra.:.god 020527 }
begin
{ dragod 020527 begin }
Sem := CreateSemaphore(nil, 0, 1, 'edk_ServSpy');
if ((Sem <> 0) and (GetLastError =
ERROR_ALREADY_EXISTS)) then
begin
CloseHandle(Sem);
ShowMessage('ServerSpy is already running.');
Halt;
end;
{ dragod 020527 end }

and at the end of the file befor end.

{ dragod 020527 start }
initialization
mHandle := CreateMutex(nil, True, 'XYZ');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
ShowMessage('ServerSpy is already running.');
halt;
end;

finalization
if mHandle <> 0 then CloseHandle(mHandle)

{ dragod 020527 end }

ive tested it and it work... servspy starts only one time...

dra.:.god