aboutsummaryrefslogtreecommitdiff
path: root/c/ext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/ext.cpp')
-rw-r--r--c/ext.cpp23
1 files changed, 23 insertions, 0 deletions
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 <ctype.h>
+#include <shlobj.h>
#include <string>
#include <string_view>
@@ -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;
+}