Revision: 8643 https://osdn.net/projects/ttssh2/scm/svn/commits/8643 Author: zmatsuo Date: 2020-03-28 00:48:19 +0900 (Sat, 28 Mar 2020) Log Message: ----------- _SHBrowseForFolderW(), _SHGetPathFromIDListW() を追加 Modified Paths: -------------- branches/unicode_macro_2/teraterm/common/compat_win.cpp branches/unicode_macro_2/teraterm/common/compat_win.h branches/unicode_macro_2/teraterm/common/layer_for_unicode.cpp branches/unicode_macro_2/teraterm/common/layer_for_unicode.h -------------- next part -------------- Modified: branches/unicode_macro_2/teraterm/common/compat_win.cpp =================================================================== --- branches/unicode_macro_2/teraterm/common/compat_win.cpp 2020-03-27 15:48:07 UTC (rev 8642) +++ branches/unicode_macro_2/teraterm/common/compat_win.cpp 2020-03-27 15:48:19 UTC (rev 8643) @@ -100,6 +100,8 @@ // shell32 UINT (WINAPI *pDragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch); BOOL (WINAPI *pShell_NotifyIconW)(DWORD dwMessage, NOTIFYICONDATAW *lpData); +PIDLIST_ABSOLUTE (WINAPI *pSHBrowseForFolderW)(LPBROWSEINFOW lpbi); +BOOL (WINAPI *pSHGetPathFromIDListW)(PCIDLIST_ABSOLUTE pidl, LPWSTR pszPath); // comctl32 HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPageW)(LPCPROPSHEETPAGEW constPropSheetPagePointer); @@ -223,6 +225,8 @@ #ifndef UNICODE_API_DISABLE { "DragQueryFileW", (void **)&pDragQueryFileW }, { "Shell_NotifyIconW", (void **)&pShell_NotifyIconW }, + { "SHBrowseForFolderW", (void **)&pSHBrowseForFolderW }, + { "SHGetPathFromIDListW", (void **)&pSHGetPathFromIDListW }, #endif {}, }; Modified: branches/unicode_macro_2/teraterm/common/compat_win.h =================================================================== --- branches/unicode_macro_2/teraterm/common/compat_win.h 2020-03-27 15:48:07 UTC (rev 8642) +++ branches/unicode_macro_2/teraterm/common/compat_win.h 2020-03-27 15:48:19 UTC (rev 8643) @@ -36,6 +36,7 @@ #pragma once #include <windows.h> +#include <shlobj.h> // for _SHBrowseForFolderW() #ifdef __cplusplus extern "C" { @@ -126,6 +127,10 @@ extern BOOL (WINAPI *pGetOpenFileNameW)(LPOPENFILENAMEW ofnW); extern BOOL (WINAPI *pGetSaveFileNameW)(LPOPENFILENAMEW ofnW); +// shlobj_core.h +extern PIDLIST_ABSOLUTE (WINAPI *pSHBrowseForFolderW)(LPBROWSEINFOW lpbi); +extern BOOL (WINAPI *pSHGetPathFromIDListW)(PCIDLIST_ABSOLUTE pidl, LPWSTR pszPath); + void WinCompatInit(); #ifdef __cplusplus Modified: branches/unicode_macro_2/teraterm/common/layer_for_unicode.cpp =================================================================== --- branches/unicode_macro_2/teraterm/common/layer_for_unicode.cpp 2020-03-27 15:48:07 UTC (rev 8642) +++ branches/unicode_macro_2/teraterm/common/layer_for_unicode.cpp 2020-03-27 15:48:19 UTC (rev 8643) @@ -581,3 +581,36 @@ free(strA); return r; } + +PIDLIST_ABSOLUTE _SHBrowseForFolderW(LPBROWSEINFOW lpbi) +{ + if (pSHBrowseForFolderW != NULL) { + return pSHBrowseForFolderW(lpbi); + } + + BROWSEINFOA biA; + biA.hwndOwner = lpbi->hwndOwner; + biA.pidlRoot = lpbi->pidlRoot; + biA.pszDisplayName = ToCharW(lpbi->pszDisplayName); + biA.lpszTitle = ToCharW(lpbi->lpszTitle); + biA.ulFlags = lpbi->ulFlags; + biA.lpfn = lpbi->lpfn; + biA.lParam = lpbi->lParam; + PIDLIST_ABSOLUTE pidlBrowse = SHBrowseForFolderA(&biA); + free(biA.pszDisplayName); + free((void *)biA.lpszTitle); + + return pidlBrowse; +} + +BOOL _SHGetPathFromIDListW(PCIDLIST_ABSOLUTE pidl, LPWSTR pszPath) +{ + if (pSHGetPathFromIDListW != NULL) { + return pSHGetPathFromIDListW(pidl, pszPath); + } + + char pathA[MAX_PATH]; + BOOL r = SHGetPathFromIDListA(pidl, pathA); + ::MultiByteToWideChar(CP_ACP, 0, pathA, -1, pszPath, MAX_PATH); + return r; +} Modified: branches/unicode_macro_2/teraterm/common/layer_for_unicode.h =================================================================== --- branches/unicode_macro_2/teraterm/common/layer_for_unicode.h 2020-03-27 15:48:07 UTC (rev 8642) +++ branches/unicode_macro_2/teraterm/common/layer_for_unicode.h 2020-03-27 15:48:19 UTC (rev 8643) @@ -36,6 +36,7 @@ #include <windows.h> #include <commdlg.h> // for _GetOpenFileNameW() +#include <shlobj.h> // for _SHBrowseForFolderW() #ifdef __cplusplus extern "C" { @@ -135,6 +136,8 @@ // shell32.lib UINT _DragQueryFileW(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch); BOOL _Shell_NotifyIconW(DWORD dwMessage, TT_NOTIFYICONDATAW_V2 *lpData); +PIDLIST_ABSOLUTE _SHBrowseForFolderW(LPBROWSEINFOW lpbi); +BOOL _SHGetPathFromIDListW(PCIDLIST_ABSOLUTE pidl, LPWSTR pszPath); HWND _CreateDialogIndirectParamW(HINSTANCE hInstance, LPCDLGTEMPLATEW lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc,