Classification: Public
There was code from NetFxChainer.cpp (CreateNetFxChainer):
hr = StrAllocFormatted(&sczName, L"%ls_mutex", wzEventName);
    ExitOnFailure(hr, "failed to allocate memory for mutex name");

    // Create the mutex, we initially own
    pChainer->hMutex = ::CreateMutex(NULL, TRUE, sczName);

so I was trying that...

it seems nothing is working... I have a MSI running and installing, another MSI 
pops up an error message that another MSI is running but my code isn't working, 
it isn't getting ERROR_ALREADY_EXISTS

steve

-----Original Message-----
From: Phil Wilson [mailto:phildgwil...@gmail.com]
Sent: January-27-15 1:25 PM
To: General discussion about the WiX toolset.
Subject: Re: [WiX-users] seeing if a MSI is running using mutex...

I'll put it this way: I don't understand why you're not passing the string 
LPCWSTR sczMutexName = L"Global\\_MSIExecute"; into CreateMutex().  Why the 
StrAllocFormatted call?

Also it's only locked during the execute sequence, and I don't know how you're 
testing it.

---------------
Phil Wilson


On Tue, Jan 27, 2015 at 10:08 AM, StevenOgilvie <sogil...@msn.com> wrote:
> What is the actual MSI mutex?
>
> Thanks
>
> Steve
>
> From: Phil Wilson [via Windows Installer XML (WiX) toolset]
> Sent: Tuesday, January 27, 2015 12:59
> To: StevenOgilvie
> Subject: Re: seeing if a MSI is running using mutex...
>
>
>
>
> It appears that your CreateMutex isn't passing in the actual MSI mutex 
> in sczMutexName .
> ---------------
> Phil Wilson
>
>
> On Tue, Jan 27, 2015 at 7:51 AM, StevenOgilvie <sogil...@msn.com> wrote:
>> Hi all,
>>
>> Trying to create a method to detect if ANY MSI is running and if so 
>> halt bootstrapper...
>> I am doing this in C++
>>
>> I get a successful mutex, but it always returns ERROR_SUCCESS, what 
>> am I doing wrong?
>> thanks
>> Steve
>>
>>
>> HANDLE ghMutex = NULL;
>> LPCWSTR sczVerifyMSIRunningVariableSet = L"0"; LPWSTR 
>> sczVerifyMSIRunningVariable = NULL; LPWSTR 
>> sczUnformattedVerifyMSIRunningVariable = NULL; LPCWSTR sczMutexName = 
>> L"Global\\_MSIExecute"; LPWSTR sczName = NULL; BOOL MutexExist = 
>> FALSE;
>>
>> // get the bootstrapper variable to change hr = 
>> BalGetStringVariable(WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING,
>> &sczUnformattedVerifyMSIRunningVariable);
>>         BalExitOnFailure1(hr, "Failed to get MSI running variable: 
>> %ls", WIXSTDBA_VARIABLE_IS_ANOTHER_MSI_RUNNING);
>>         hr = BalFormatString(sczUnformattedVerifyMSIRunningVariable,
>> &sczVerifyMSIRunningVariable);
>>         BalExitOnFailure1(hr, "Failed to format get MSI running variable:
>> %ls", sczUnformattedVerifyMSIRunningVariable);
>> hr = StrAllocFormatted(&sczName, L"%ls", sczMutexName);
>>         ::MessageBoxW(m_hWnd, (LPCWSTR)sczName, 
>> (LPCWSTR)m_pTheme->sczCaption, MB_OK | MB_ICONWARNING);
>>
>>         // check to see if any MSI is running
>>         ghMutex = ::CreateMutex(
>>         NULL,                   // default security attributes
>>         FALSE,                  // initially not owned
>>         sczName);               // product name
>>
>>         if (ghMutex != NULL)
>>         {
>>             ::MessageBoxW(m_hWnd, L"ghMutex was not null", 
>> (LPCWSTR)m_pTheme->sczCaption, MB_OK | MB_ICONWARNING);
>>
>>             switch (GetLastError())
>>             {
>>                 case ERROR_SUCCESS:
>>                     // Mutex created successfully. There is no 
>> instance running
>>                     ::MessageBoxW(m_hWnd, L"ghMutex: Mutex created 
>> successfully. There is no instance running FALSE", 
>> (LPCWSTR)m_pTheme->sczCaption, MB_OK | MB_ICONWARNING);
>>                     MutexExist = FALSE;
>>                     break;
>>                 case ERROR_ALREADY_EXISTS:
>>                     // Mutex already exists so there is a running instance
>>                     ::MessageBoxW(m_hWnd, L"ghMutex: Mutex already 
>> exists so there is a running instance TRUE", 
>> (LPCWSTR)m_pTheme->sczCaption, MB_OK | MB_ICONWARNING);
>>                     MutexExist = TRUE;
>>                     break;
>>                 default:
>>                     // Failed to create Mutex by unknown reason
>>                     ::MessageBoxW(m_hWnd, L"ghMutex: Failed to create 
>> Mutex by unknown reason FALSE", (LPCWSTR)m_pTheme->sczCaption, MB_OK
>> | MB_ICONWARNING);
>>                     MutexExist = FALSE;
>>                     break;
>>                     }
>>         }
>>
>>         if (MutexExist)
>>         {
>>             sczVerifyMSIRunningVariableSet = L"1";
>>         }
>>
>> // a MSI is installing
>>         hr =
>> m_pEngine->SetVariableString(LPCWSTR(sczVerifyMSIRunningVariable),
>> sczVerifyMSIRunningVariableSet);
>>
>>
>>

 
This message has been marked as Public by Steven Ogilvie on January-27-15 
1:56:22 PM.

The above classification labels were added to the message by TITUS Message 
Classification. 
For more information visit www.titus.com.

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to