From ab440290c6fd84ca1c9b7240ac9c90147d4660eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 23 Jan 2023 01:05:37 +0100 Subject: Add Show In Explorer context menu item. --- c/ext.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'c/ext.cpp') diff --git a/c/ext.cpp b/c/ext.cpp index 3c9542b..33218d2 100644 --- a/c/ext.cpp +++ b/c/ext.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -119,3 +120,25 @@ bool OpenLocally(CfgA& cfg, const ElvDataA& e) } else return false; } + +bool ShowInExplorer(CfgA& cfg, const ElvDataA& e) +{ + wchar_t file[MAX_PATH]; + if (FindMatchingFile(file, cfg.root, e.siEp)) { + /* ILCreateFromPath does not support forward slashes. */ + for (wchar_t *f = file; *f; f++) + if (*f == L'/') + *f = L'\\'; + + if (ITEMIDLIST* idl = ILCreateFromPath(file)) { + HRESULT r = SHOpenFolderAndSelectItems(idl, 0, 0, 0); + ILFree(idl); + if (FAILED(r)) { + SetLastError(r); + throw Err(WINDOWS, L"File "s + file + L" could not be shown in Explorer"); + } + } + return true; + } else + return false; +} -- cgit v1.2.3