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); -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/seeing-if-a-MSI-is-running-using-mutex-tp7599025.html Sent from the wix-users mailing list archive at Nabble.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