@@ -26,9 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2626#include < shlwapi.h>
2727#include < shlobj.h>
2828#include < dbt.h>
29- #include < atlbase.h>
30-
3129#include < ranges>
30+ #include < wrl/client.h>
3231
3332#include " NppInterface.h"
3433#include " ExplorerDialog.h"
@@ -241,10 +240,10 @@ extern "C" __declspec(dllexport) void setInfo(NppData notpadPlusData)
241240 helpDlg .init (g_hInst, g_nppData._nppHandle );
242241
243242 explorerDlg.VisibleChanged ([](bool visible) {
244- ::SendMessage (g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[0 ]._cmdID, (LPARAM)visible);
243+ ::SendMessage (g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[DOCKABLE_EXPLORER_INDEX ]._cmdID, (LPARAM)visible);
245244 });
246245 favesDlg.VisibleChanged ([](bool visible) {
247- ::SendMessage (g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[1 ]._cmdID, (LPARAM)visible);
246+ ::SendMessage (g_nppData._nppHandle, NPPM_SETMENUITEMCHECK, funcItem[DOCKABLE_FAVORTIES_INDEX ]._cmdID, (LPARAM)visible);
248247 });
249248
250249 /* Subclassing for Notepad */
@@ -896,46 +895,40 @@ void ExtractIcons(LPCTSTR currentPath, LPCTSTR fileName, DevType type, LPINT piI
896895}
897896
898897// Resolve files if they are shortcuts
899- HRESULT ResolveShortCut (const std::wstring &shortcutPath, LPTSTR lpszFilePath, int maxBuf)
898+ HRESULT ResolveShortCut (const std::wstring &shortcutPath, LPWSTR lpszFilePath, int maxBuf)
900899{
901- HRESULT hRes = S_FALSE;
902- CComPtr<IShellLink> ipShellLink;
903- lpszFilePath[0 ] = ' \0 ' ;
904-
905- // Get a pointer to the IShellLink interface
906- hRes = CoCreateInstance (CLSID_ShellLink,
907- nullptr ,
908- CLSCTX_INPROC_SERVER,
909- IID_IShellLink,
910- (void **)&ipShellLink);
911-
912- if (hRes == S_OK) {
913- // Get a pointer to the IPersistFile interface
914- CComQIPtr<IPersistFile> ipPersistFile (ipShellLink);
915-
916- // Open the shortcut file and initialize it from its contents
917- hRes = ipPersistFile->Load (shortcutPath.c_str (), STGM_READ);
918- if (hRes == S_OK) {
919- // Try to find the target of a shortcut, even if it has been moved or renamed
920- hRes = ipShellLink->Resolve (nullptr , SLR_UPDATE);
921- if (hRes == S_OK) {
922- // Get the path to the shortcut target
923- WCHAR szPath[MAX_PATH];
924- hRes = ipShellLink->GetPath (szPath, MAX_PATH, nullptr , SLGP_RAWPATH);
925- if (hRes == S_OK) {
926- _tcsncpy (lpszFilePath, szPath, maxBuf);
927-
928- if (::PathIsDirectory (lpszFilePath) != FALSE ) {
929- if (lpszFilePath[wcslen (lpszFilePath) - 1 ] != ' \\ ' ) {
930- wcsncat (lpszFilePath, L" \\ " , MAX_PATH);
931- }
932- }
933- }
934- }
935- }
900+ Microsoft::WRL::ComPtr<IShellLink> shellLink;
901+ HRESULT hr = CoCreateInstance (CLSID_ShellLink, nullptr , CLSCTX_INPROC_SERVER, IID_PPV_ARGS (&shellLink));
902+ if (FAILED (hr)) {
903+ return hr;
904+ }
905+
906+ Microsoft::WRL::ComPtr<IPersistFile> persistFile;
907+ hr = shellLink.As (&persistFile);
908+ if (FAILED (hr)) {
909+ return hr;
910+ }
911+
912+ hr = persistFile->Load (shortcutPath.c_str (), STGM_READ);
913+ if (FAILED (hr)) {
914+ return hr;
915+ }
916+
917+ hr = shellLink->Resolve (nullptr , SLR_UPDATE);
918+ if (FAILED (hr)) {
919+ return hr;
920+ }
921+
922+ hr = shellLink->GetPath (lpszFilePath, maxBuf, nullptr , SLGP_RAWPATH);
923+ if (FAILED (hr)) {
924+ return hr;
925+ }
926+
927+ if (::PathIsDirectory (lpszFilePath) && lpszFilePath[wcslen (lpszFilePath) - 1 ] != L' \\ ' ) {
928+ wcsncat_s (lpszFilePath, maxBuf, L" \\ " , 1 );
936929 }
937930
938- return hRes ;
931+ return S_OK ;
939932}
940933
941934
0 commit comments