aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/Shell.cpp
diff options
context:
space:
mode:
authorIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-05-14 00:00:00 +0000
committerIgor Pavlov <87184205+ip7z@users.noreply.github.com>2024-05-15 23:55:04 +0500
commitfc662341e6f85da78ada0e443f6116b978f79f22 (patch)
tree1be1cc402a7a9cbc18d4eeea6b141354c2d559e3 /CPP/Windows/Shell.cpp
parent5b39dc76f1bc82f941d5c800ab9f34407a06b53a (diff)
download7zip-24.05.tar.gz
7zip-24.05.tar.bz2
7zip-24.05.zip
24.0524.05
Diffstat (limited to 'CPP/Windows/Shell.cpp')
-rw-r--r--CPP/Windows/Shell.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/CPP/Windows/Shell.cpp b/CPP/Windows/Shell.cpp
index b2a3489..01ceb22 100644
--- a/CPP/Windows/Shell.cpp
+++ b/CPP/Windows/Shell.cpp
@@ -162,7 +162,7 @@ static HRESULT ReadAnsiStrings(const char *p, size_t size, UStringVector &names)
162 name.Empty(); 162 name.Empty();
163 } 163 }
164 else 164 else
165 name += c; 165 name.Add_Char(c);
166 } 166 }
167 return E_INVALIDARG; 167 return E_INVALIDARG;
168} 168}
@@ -543,8 +543,18 @@ void CDrop::QueryFileNames(UStringVector &fileNames)
543typedef int Z7_WIN_GPFIDL_FLAGS; 543typedef int Z7_WIN_GPFIDL_FLAGS;
544 544
545extern "C" { 545extern "C" {
546typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath); 546#ifndef _UNICODE
547typedef BOOL (WINAPI * Func_SHGetPathFromIDListEx)(LPCITEMIDLIST pidl, PWSTR pszPath, DWORD cchPath, Z7_WIN_GPFIDL_FLAGS uOpts); 547typedef BOOL (WINAPI * Func_SHGetPathFromIDListW)(LPCITEMIDLIST pidl, LPWSTR pszPath); // nt4
548#endif
549
550#if !defined(Z7_WIN32_WINNT_MIN) || Z7_WIN32_WINNT_MIN < 0x0600 // Vista
551#define Z7_USE_DYN_SHGetPathFromIDListEx
552#endif
553
554#ifdef Z7_USE_DYN_SHGetPathFromIDListEx
555Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION
556typedef BOOL (WINAPI * Func_SHGetPathFromIDListEx)(LPCITEMIDLIST pidl, PWSTR pszPath, DWORD cchPath, Z7_WIN_GPFIDL_FLAGS uOpts); // vista
557#endif
548} 558}
549 559
550#ifndef _UNICODE 560#ifndef _UNICODE
@@ -584,18 +594,26 @@ bool GetPathFromIDList(LPCITEMIDLIST itemIDList, UString &path)
584 /* for long path we need SHGetPathFromIDListEx(). 594 /* for long path we need SHGetPathFromIDListEx().
585 win10: SHGetPathFromIDListEx() for long path returns path with 595 win10: SHGetPathFromIDListEx() for long path returns path with
586 with super path prefix "\\\\?\\". */ 596 with super path prefix "\\\\?\\". */
597#ifdef Z7_USE_DYN_SHGetPathFromIDListEx
587 const 598 const
588 Func_SHGetPathFromIDListEx 599 Func_SHGetPathFromIDListEx
589 func_SHGetPathFromIDListEx = Z7_GET_PROC_ADDRESS( 600 func_SHGetPathFromIDListEx = Z7_GET_PROC_ADDRESS(
590 Func_SHGetPathFromIDListEx, ::GetModuleHandleW(L"shell32.dll"), 601 Func_SHGetPathFromIDListEx, ::GetModuleHandleW(L"shell32.dll"),
591 "SHGetPathFromIDListEx"); 602 "SHGetPathFromIDListEx");
592 if (func_SHGetPathFromIDListEx) 603 if (func_SHGetPathFromIDListEx)
604#endif
593 { 605 {
594 ODS("==== GetPathFromIDList() (SHGetPathFromIDListEx)") 606 ODS("==== GetPathFromIDList() (SHGetPathFromIDListEx)")
595 do 607 do
596 { 608 {
597 len *= 4; 609 len *= 4;
598 result = BOOLToBool(func_SHGetPathFromIDListEx(itemIDList, path.GetBuf(len), len, 0)); 610 result = BOOLToBool(
611#ifdef Z7_USE_DYN_SHGetPathFromIDListEx
612 func_SHGetPathFromIDListEx
613#else
614 SHGetPathFromIDListEx
615#endif
616 (itemIDList, path.GetBuf(len), len, 0));
599 if (result) 617 if (result)
600 break; 618 break;
601 } 619 }