🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.nativeapi
Article #12072

Basic problem with Mutex

#12072
From: Philippe Chessa
Date: Mon, 25 Nov 2002 10:57
28 lines
1749 bytes
Hi all, 

I have 2 applications A and B: application A (files transfert) cannot run when application B is active (files generation). 
I try to use a mutex to handle this issue.

I was wondering what was wrong in the following code: when pressing the button, after the 1st execution, the mutex is always present
===============================================
procedure TForm1.Button2Click(Sender: TObject);
var
  H: Cardinal;
begin
  H := CreateMutex(NIL, FALSE, MTV_MUTEX_RUNNING);
  if GetLastError = ERROR_ALREADY_EXISTS then
  begin
    Edit1.Text := 'MUTEX already exists';
  end
  else
  begin
    Edit1.Text := 'MUTEX does not exist';
  end;
  ReleaseMutex(H);
end;
===============================================

(D5 under Win NT 4)

Thanks very much in advance
Technical Details
Message-ID: <3de20217$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,7525dbf6d7ec72a3,start
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2002-11-25 03:15:54 PST
From: "Philippe Chessa" <pchessa@peaktime.fr>
Sender: "Philippe Chessa" <pchessa@peaktime.fr>
Reply-To: "Philippe Chessa" <pchessa@peaktime.fr>
Subject: Basic problem with Mutex 
Newsgroups: borland.public.delphi.nativeapi
X-User-Info: 146.220.240.49 146.220.240.49    
X-Forwarded-For: 146.220.254.108
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3de20217$1@newsgroups.borland.com>
Date: 25 Nov 2002 02:57:27 -0800
X-Trace: newsgroups.borland.com 1038221847 207.105.83.65 (25 Nov 2002 02:57:27 -0800)
Lines: 29
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail