Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   problem with OpenMutexA (getting result). (http://forums.winamp.com/showthread.php?t=268642)

MVI 30th March 2007 10:18

problem with OpenMutexA (getting result).
 
Greetings...

By the following code:
code:

MessageBox MB_OK "TEST"

CheckApp:
System::Call 'kernel32::OpenMutexA(i 0, i 0, t "{D50A79A4-CFD5-49a0-B94E-BBFA1D974616}") i .r1'
IntCmp $R1 0 +3
MessageBox MB_OK "App is running."
GoTo CheckApp


i'm trying to check if my app. is running.
But I can't see any "App is running." MessageBoxes...
(App is running and it has mutex with such name. I can see "TEST" MessageBox.)

What I'm doing wrong?

Best regards...

Red Wine 30th March 2007 12:02

If your app is the running installer, take a look here,

http://nsis.sourceforge.net/Allow_on...aller_instance

MVI 30th March 2007 12:53

My app not an installer. And I've already saw that code. But my question not about it...

Red Wine 30th March 2007 13:04

Then, perhaps you might want to take a look on this,

http://nsis.sourceforge.net/FindProcDLL_plug-in

MVI 30th March 2007 13:35

Thats completely nothing of the kind I neded...
All that I need, is just point on my error (with correction).
For example this:
code:

CheckForApp:
System::Call "kernel32::CreateMutexA(i 0, i 0, t "{B1454C40-EAFE-4124-809F-90DEC53E06EC}") ?e"
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK "Please close App before continue."
GoTo CheckForApp


code (changed from http://nsis.sourceforge.net/Allow_on...aller_instance)
Always shows "Please close App before continue." independently of test application presence...

Anders 30th March 2007 13:37

Your quotes are messed up, escape " or use '

PHP Code:

System::Call 'kernel32::CreateMutexA(... t "foo" ) ?e' 


MVI 30th March 2007 14:07

in second and third examles of http://nsis.sourceforge.net/Allow_on...aller_instance used double-quotes...
also i've tried and nothing changed...

Comm@nder21 30th March 2007 18:10

1. you'll need to use the different quotes.

2. you missed to specify an output argument:

System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{B1454C40-EAFE-4124-809F-90DEC53E06EC}") i .n ?e'

MVI 2nd April 2007 08:02

I'm actually need help with my first "code"...
There are single quotes and there is output argument....

kichik 2nd April 2007 10:21

And what's the code you've used in your application?

MVI 2nd April 2007 11:15

I've created two applications.
One, fore creating mutex:
code:
HANDLE mutex = ::CreateMutex(NULL, TRUE, L"{B1454C40-EAFE-4124-809F-90DEC53E06EC}");
while (1)
Sleep(1000);


and one, for check this mutex:
code:
while (1)
{
HANDLE mutex = ::OpenMutex(READ_CONTROL, FALSE, L"{B1454C40-EAFE-4124-809F-90DEC53E06EC}");
if (mutex != 0)
{
CloseHandle(mutex);

MessageBox(NULL, L"Please close App before continue.", NULL, MB_OK);
}
else
Sleep(1000);
}


Comm@nder21 2nd April 2007 18:04

if you got problems with your first code, it's missing the error output:

Quote:

System::Call 'kernel32::OpenMutexA(i 0, i 0, t "{D50A79A4-CFD5-49a0-B94E-BBFA1D974616}") i .r1'
you need the ?e at the end, because r1 won't tell you anything about the mutex. only the call of GetErrorSomethingBla which is done by ?e will give you the info whether the mutex could have been created or not.


use the code i submitted previously and it will work (i'm using it all the time with my codes)

MVI 3rd April 2007 07:44

I've changed my code:
code:
CheckForApp:
System::Call 'kernel32::OpenMutexA(i 0x00020000, i 0, t "{B1454C40-EAFE-4124-809F-90DEC53E06EC}") i .r1 ?e'
StrCmp $R1 0 AppNotRunning
MessageBox MB_OK "Please close App before continue."
GoTo CheckForApp
AppNotRunning:


but MessageBox appears independently of mutex presence...

kichik 3rd April 2007 08:14

The error value goes into $1 but you check $R1. Check $1 or change r1 to R1.

MVI 3rd April 2007 08:26

thanks. now it works.


All times are GMT. The time now is 04:11.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.