Thanks Phil, I have “modified” it a bit but it still blows chunks when reaching the MsiLocateComponent method
Header file: #include <Msi.h> // For MsiLocateComponent call // To fix MSI linking errors #pragma comment(lib, "msi.lib") CPP file: static const LPCWSTR WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED = L"VerifyWordPIAIsInstalled"; static const LPCWSTR WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED_ERROR_MSG = L"VerifyWordPIAIsInstalledErrorMsg"; HRESULT hr = S_OK; LONGLONG lIVerifyWordPIAIsInstalled = 0; BOOL fAdvanceToOptionsPageWordPIAInstalled = TRUE; // Verify that the Client install has Word PIA installed hr = BalGetNumericVariable(WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED, &lIVerifyWordPIAIsInstalled); BalExitOnFailure1(hr, "Failed to get verify Word PIA is installed for Outlook variable: %ls", WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Verify Word PIA is installed for Outlook: %d", (DWORD)lIVerifyWordPIAIsInstalled); if (lIVerifyWordPIAIsInstalled == 1) { fAdvanceToOptionsPageWordPIAInstalled = IsWordPIAInstalledForClientSelected(); } // // IsWordPIAInstalledForClientSelected - Ensure at least one version of Office has been installed // In Bundle.wxs set the variable: VerifyWordPIAIsInstalled to 1 to run this function // set the variable: VerifyWordPIAIsInstalledErrorMsg (WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED_ERROR_MSG) to some error message string // bool IsWordPIAInstalledForClientSelected() { HRESULT hr = S_OK; LPWSTR sczUnformattedVerifyWordPIAIsInstalledErrorMsg = NULL; LPWSTR sczVerifyWordPIAIsInstalledErrorMsg = NULL; BOOL fValidateWordPIAInstalled = TRUE; BOOL fValidateComponentExists = TRUE; HKEY hkRoot = HKEY_LOCAL_MACHINE; HKEY hkKey = NULL; const LPCWSTR sczOutlookSubKey = L"SOFTWARE\\Microsoft\\Office\\15.0\\Outlook"; const LPCWSTR sczBitness = L"Bitness"; const LPCWSTR sczX86 = L"x86"; const LPCWSTR sczX64 = L"x64"; LPWSTR sczOutlookBitness = NULL; DWORD dwFileAttributes = 0; LPCWSTR sczComponentIdx86 = L"{9FE736B7-B1EE-410C-8D07-082891C3DAC8}"; LPCWSTR sczComponentIdx64 = L"{13C07AF5-B206-4A48-BB5B-B8022333E3CA}"; INSTALLSTATE installState; LPWSTR *sczPath = NULL; DWORD pcchBuf[MAX_PATH]; DWORD dwIndex; LPCWSTR sczFoundStrIn = NULL; if ( ThemeIsControlChecked(m_pTheme, WIXSTDBA_CONTROL_CHECKBOX_CLIENT1) ) { // Check the HKLM\SOFTWARE\Microsoft\Office\15.0\Outlook hr = RegOpen(hkRoot, sczOutlookSubKey, KEY_READ, &hkKey); if (SUCCEEDED(hr)) { hr = RegReadString(hkKey, sczBitness, &sczOutlookBitness); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Bitness of Outlook is: %ls", sczOutlookBitness); if (SUCCEEDED(hr)) { // now check the componentId for the Word PIA and see if it exists hr = MultiSzFindSubstring(sczOutlookBitness, sczX86, &dwIndex, &sczFoundStrIn); if (S_OK == hr) { BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Checking the x86 version of the Word PIA"); installState = ::MsiLocateComponentW(sczComponentIdx86, *sczPath, pcchBuf); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieve the install state of x86 Word PIA: %ls", installState); // Check to see if the path for the component exists fValidateComponentExists = FileExistsEx((LPCWSTR)sczPath, &dwFileAttributes); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieve the install path of x86 Word PIA: %ls", sczPath); // If the component is not installed or unknown AND the component path doesn't exist fail if ( (installState == INSTALLSTATE_UNKNOWN || installState == INSTALLSTATE_ABSENT) && !fValidateComponentExists ) { BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "InstallState of Word x86 PIA is %ls", installState); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Install path of Word x86 PIA is %ls", sczPath); fValidateWordPIAInstalled = FALSE; } } hr = MultiSzFindSubstring(sczOutlookBitness, sczX64, &dwIndex, &sczFoundStrIn); if (S_OK == hr) { BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Checking the x64 version of the Word PIA"); installState = ::MsiLocateComponentW(sczComponentIdx64, *sczPath, pcchBuf); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieve the install state of x64 Word PIA: %ls", installState); // Check to see if the path for the component exists fValidateComponentExists = FileExistsEx((LPCWSTR)sczPath, &dwFileAttributes); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Retrieve the install path of x64 Word PIA: %ls", sczPath); // If the component is not installed or unknown AND the component path doesn't exist fail if ( (INSTALLSTATE_UNKNOWN == installState || INSTALLSTATE_ABSENT == installState) && !fValidateComponentExists ) { BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "InstallState of Word x64 PIA is %ls", installState); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Install path of Word x64 PIA is %ls", sczPath); fValidateWordPIAInstalled = FALSE; } } } } if (!fValidateWordPIAInstalled) { hr = BalGetStringVariable(WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED_ERROR_MSG, &sczUnformattedVerifyWordPIAIsInstalledErrorMsg); BalExitOnFailure1(hr, "Failed to get verify Word PIA installed variable: %ls", WIXSTDBA_VARIABLE_VERIFY_WORD_PIA_INSTALLED_ERROR_MSG); hr = BalFormatString(sczUnformattedVerifyWordPIAIsInstalledErrorMsg, &sczVerifyWordPIAIsInstalledErrorMsg); BalExitOnFailure1(hr, "Failed to format verify Word PIA installed variable: %ls", sczUnformattedVerifyWordPIAIsInstalledErrorMsg); ::MessageBoxW(m_hWnd, sczVerifyWordPIAIsInstalledErrorMsg, m_pTheme->sczCaption, MB_OK | MB_ICONEXCLAMATION); BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, "Could not find any versions of Word PIA."); return FALSE; } } LExit: ReleaseStr(sczUnformattedVerifyWordPIAIsInstalledErrorMsg); ReleaseStr(sczVerifyWordPIAIsInstalledErrorMsg); ReleaseStr(sczOutlookBitness); ReleaseStr(sczPath); ReleaseRegKey(hkKey); return TRUE; } Thanks, Steve -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Trying-to-use-MsiLocatecomponent-in-Bootstrapper-to-check-for-a-Word-PIA-tp7594186p7594262.html Sent from the wix-devs mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ WiX-devs mailing list WiX-devs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-devs