diff options
| author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-07-16 00:00:00 +0000 |
|---|---|---|
| committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2023-12-17 14:35:38 +0500 |
| commit | 93be7d4abfd4233228f58ee1fbbcd76d91be66a4 (patch) | |
| tree | 9b11631a70ca7150321838d9d6bd473e52d6684d /CPP/Windows/Shell.cpp | |
| parent | a3e1d227377188734b82f023f96f8e25dc40f3e6 (diff) | |
| download | 7zip-93be7d4abfd4233228f58ee1fbbcd76d91be66a4.tar.gz 7zip-93be7d4abfd4233228f58ee1fbbcd76d91be66a4.tar.bz2 7zip-93be7d4abfd4233228f58ee1fbbcd76d91be66a4.zip | |
22.0122.01
Diffstat (limited to 'CPP/Windows/Shell.cpp')
| -rw-r--r-- | CPP/Windows/Shell.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/CPP/Windows/Shell.cpp b/CPP/Windows/Shell.cpp index d0f9032..071833c 100644 --- a/CPP/Windows/Shell.cpp +++ b/CPP/Windows/Shell.cpp | |||
| @@ -258,14 +258,21 @@ bool BrowseForFolder(HWND owner, LPCTSTR title, | |||
| 258 | 258 | ||
| 259 | #ifndef _UNICODE | 259 | #ifndef _UNICODE |
| 260 | 260 | ||
| 261 | typedef BOOL (WINAPI * SHGetPathFromIDListWP)(LPCITEMIDLIST pidl, LPWSTR pszPath); | 261 | extern "C" { |
| 262 | typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath); | ||
| 263 | typedef LPITEMIDLIST (WINAPI * Func_SHBrowseForFolderW)(LPBROWSEINFOW lpbi); | ||
| 264 | } | ||
| 265 | |||
| 266 | #define MY_CAST_FUNC (void(*)()) | ||
| 267 | // #define MY_CAST_FUNC | ||
| 262 | 268 | ||
| 263 | bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path) | 269 | bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path) |
| 264 | { | 270 | { |
| 265 | path.Empty(); | 271 | path.Empty(); |
| 266 | SHGetPathFromIDListWP shGetPathFromIDListW = (SHGetPathFromIDListWP) | 272 | Func_SHGetPathFromIDListW shGetPathFromIDListW = (Func_SHGetPathFromIDListW) |
| 273 | MY_CAST_FUNC | ||
| 267 | ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetPathFromIDListW"); | 274 | ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetPathFromIDListW"); |
| 268 | if (shGetPathFromIDListW == 0) | 275 | if (!shGetPathFromIDListW) |
| 269 | return false; | 276 | return false; |
| 270 | const unsigned len = MAX_PATH * 2; | 277 | const unsigned len = MAX_PATH * 2; |
| 271 | bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuf(len))); | 278 | bool result = BOOLToBool(shGetPathFromIDListW(itemIDList, path.GetBuf(len))); |
| @@ -273,14 +280,14 @@ bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path) | |||
| 273 | return result; | 280 | return result; |
| 274 | } | 281 | } |
| 275 | 282 | ||
| 276 | typedef LPITEMIDLIST (WINAPI * SHBrowseForFolderWP)(LPBROWSEINFOW lpbi); | ||
| 277 | 283 | ||
| 278 | static bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath) | 284 | static bool BrowseForFolder(LPBROWSEINFOW browseInfo, UString &resultPath) |
| 279 | { | 285 | { |
| 280 | NWindows::NCOM::CComInitializer comInitializer; | 286 | NWindows::NCOM::CComInitializer comInitializer; |
| 281 | SHBrowseForFolderWP shBrowseForFolderW = (SHBrowseForFolderWP) | 287 | Func_SHBrowseForFolderW shBrowseForFolderW = (Func_SHBrowseForFolderW) |
| 288 | MY_CAST_FUNC | ||
| 282 | ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHBrowseForFolderW"); | 289 | ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHBrowseForFolderW"); |
| 283 | if (shBrowseForFolderW == 0) | 290 | if (!shBrowseForFolderW) |
| 284 | return false; | 291 | return false; |
| 285 | LPITEMIDLIST itemIDList = shBrowseForFolderW(browseInfo); | 292 | LPITEMIDLIST itemIDList = shBrowseForFolderW(browseInfo); |
| 286 | if (itemIDList == NULL) | 293 | if (itemIDList == NULL) |
