Archive: Problem with CreateMutexA and detecting an application running


Problem with CreateMutexA and detecting an application running
  I have searched most of the messages that I could find referencing the createmutexa function for detecting if an application is running (as well as the FindWindow versions) but I could not seem to resolve this issue.

What I want is to detect 2 instances:

1. Whether the installer is running
2. Whther the application I am installing is actually running.

I can use the one instance already supplied on the FAQ for detecting the installer without issue. When attempting to use the CreateMutexA again It detects the application is running and posts the Retry Cancel options but the Retry always believes the actual application is still running even when it has been killed?!? It is in a loop somehow with the again: label before the CreatMutexA command is executed again apparently and I do not know why?

Here is my Code Script:


onInit


System
::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME} Installer") i .r1 ?e'

Pop $R0

StrCmp $R0 0+3
MessageBox MB_OK "${PRODUCT_NAME} installer is already running"
Abort

again:
>System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME}") i .r1 ?e'


Pop $R1

StrCmp $R1 0+3
MessageBox MB_RETRYCANCEL|MB_ICONSTOP "${PRODUCT_NAME} must not be running in order to proceeed with installation" IDRETRY again IDCANCEL
Abort

FunctionEnd
>
If someone can point out what I am doing wrong or how I can do it differently (other than FindWindow since window name has not been officially established as yet") I would appreciate the help.

Thanks

Maybe I'm wrong but the problem with your code is that plugins doesn't allow goto statments, in your case again: for example.
And, see this:


System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${PRODUCT_NAME} Installer") i .r1'
Pop $R0

you are returning number, so you might use IntCmp instead.

Lobo Lunar, that is not true. You can use Goto everywhere.

All variables are strings. For a simple comparation you can use StrCmp, that makes no difference.


I guess I keep the old fashion way :)
Thanks! for the update :D