 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
KennyT
Joined: 02 Aug 2005 Posts: 318
|
Posted: Fri May 27, 2011 12:29 pm Post subject: How to use CreateMutEx? |
|
|
I want to have an installation package do a check for an existing running copy of the program, so it can warn the user to close the app before trying to do the install. I've been advised that the way to do this is to call CreateMutEx, which I've been trying to do, but it always returns 0 (with a GetlastError returning 998, if I put the call in a DLL, or 1305 if it's in the main EXE)
I've tried:
IRET = CreateMutEx (0,.FALSE.,progname)
IRET = CreateMutEx (NULL,.FALSE.,progname)
IRET = CreateMutEx (NULL,.FALSE.,progname//CHAR(0))
IRET = CreateMutEx (NULL,LRET,progname) ! LRET::LOGICAL*4=.FALSE.
IRET = CreateMutEx (NULL,LRET,progname) ! LRET::LOGICAL*1=.FALSE.
And various other combinations, always with the same result.
Has anyone successfully used this call from FTN95? What's the trick?
TIA
K |
|
Back to top |
|
 |
KennyT
Joined: 02 Aug 2005 Posts: 318
|
Posted: Sat May 28, 2011 10:15 am Post subject: |
|
|
OK, found the trick!
The problem is the STDCALL definition in the WIN32API.INS file:
STDCALL CREATEMUTEX 'CreateMutexA' (REF,VAL,STRING):INTEGER*4
Having the "REF" in there makes it rather difficult to pass a NULL pointer as required by the API, when using this form of the call. Defining my own version, using a VAL, makes the call work:
STDCALL CREATEMUTEXK 'CreateMutexA' (VAL,VAL,STRING):INTEGER*4
K |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Tue May 31, 2011 3:35 pm Post subject: |
|
|
Kenny,
While I am prepared to believe that it is possible to write an installation program in FTN95 and Clearwin, I'm not sure that it is an easy or satisfying task. Indeed, I gave up even before writing a single line of code. Partly it was a fear that the task would be long and frustrating, but even more so, there are free tools to do the job.
I have discovered that I am not alone in using Jordan Russell's InnoSetup (just Google and you will find his site). Not least among the many plus points for this software is the creation of a single, packed, EXE file containing your whole application, DLLs, demo files, self-instuction Powerpoints, CHM help files and all the rest.
Eddie
Edit: You may even find this helpful even if you go your own way:
http://www.jrsoftware.org/iskb.php?mutexsessions
It looks like a foreign language to me!
E |
|
Back to top |
|
 |
KennyT
Joined: 02 Aug 2005 Posts: 318
|
Posted: Wed Jun 01, 2011 7:46 am Post subject: |
|
|
Indeed, it is InnoSetup that I am using (and it's rather good!), but in order to detect a running instance of my application when the installer runs, I need to use CreateMutEx in my application for the AppMutex directive in Innosetup to work, hence the original enquiry.
K |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2402 Location: Yateley, Hants, UK
|
Posted: Wed Jun 01, 2011 12:07 pm Post subject: |
|
|
Now I understand why so many installation routines ask you to close any relevant applications - their programmers haven't mastered this, have they?
Something else for me to add to my list of things I would like to understand ...
E |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|