From 3756ae7c8dc60d459511d0b067ebef5efb052746 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 10 Aug 2022 19:24:24 -0500 Subject: Use IFileOpenDialog instead of SHBrowseForFolder and GetOpenFileName. It is the recommended option since Vista and has better long path support. --- .../WixStandardBootstrapperApplication.cpp | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/ext') diff --git a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp index d7b5a269..8544ff0e 100644 --- a/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp +++ b/src/ext/Bal/wixstdba/WixStandardBootstrapperApplication.cpp @@ -1145,26 +1145,19 @@ public: // IBootstrapperApplication ) { HRESULT hr = S_OK; + LPWSTR sczPath = NULL; if (BOOTSTRAPPER_CACHE_RESOLVE_NONE == *pAction && BOOTSTRAPPER_DISPLAY_FULL == m_command.display) // prompt to change the source location. { - OPENFILENAMEW ofn = { }; - WCHAR wzFile[MAX_PATH] = { }; - - ::StringCchCopyW(wzFile, countof(wzFile), rgSearchPaths[dwRecommendedSearchPath]); - - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = m_hWnd; - ofn.lpstrFile = wzFile; - ofn.nMaxFile = countof(wzFile); - ofn.lpstrFilter = L"All Files\0*.*\0"; - ofn.nFilterIndex = 1; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - ofn.lpstrTitle = m_pTheme->sczCaption; + static COMDLG_FILTERSPEC vrgFilters[] = + { + { L"All Files", L"*.*" }, + }; - if (::GetOpenFileNameW(&ofn)) + hr = WnduShowOpenFileDialog(m_hWnd, TRUE, TRUE, m_pTheme->sczCaption, vrgFilters, countof(vrgFilters), 1, rgSearchPaths[dwRecommendedSearchPath], &sczPath); + if (SUCCEEDED(hr)) { - hr = m_pEngine->SetLocalSource(wzPackageOrContainerId, wzPayloadId, ofn.lpstrFile); + hr = m_pEngine->SetLocalSource(wzPackageOrContainerId, wzPayloadId, sczPath); *pAction = BOOTSTRAPPER_CACHE_RESOLVE_RETRY; } else @@ -1175,6 +1168,9 @@ public: // IBootstrapperApplication // else there's nothing more we can do in non-interactive mode *pfCancel |= CheckCanceled(); + + ReleaseStr(sczPath); + return hr; } -- cgit v1.2.3-55-g6feb