-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathShellFilePreviewHandler.cs
More file actions
38 lines (27 loc) · 1.04 KB
/
ShellFilePreviewHandler.cs
File metadata and controls
38 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.IO;
using Windows.Win32;
using Windows.Win32.UI.Shell;
using WinQuickLook.Controls;
using WinQuickLook.Extensions;
namespace WinQuickLook.Handlers;
public class ShellFilePreviewHandler : FilePreviewHandler
{
public override HandlerPriorityClass PriorityClass => HandlerPriorityClass.BelowNormal;
protected override bool TryCreateViewer(FileInfo fileInfo, out HandlerResult? handlerResult)
{
var pcchOut = 0u;
var riid = typeof(IPreviewHandler).GUID.ToString("B");
if (PInvoke.AssocQueryString(ASSOCF.ASSOCF_INIT_DEFAULTTOSTAR, ASSOCSTR.ASSOCSTR_SHELLEXTENSION, fileInfo.Extension, riid, [], ref pcchOut).Failed)
{
handlerResult = default;
return false;
}
var shellFileControl = new ShellFileControl();
using (shellFileControl.Initialize())
{
shellFileControl.Loaded += (_, _) => shellFileControl.Open(fileInfo);
}
handlerResult = new HandlerResult { Content = shellFileControl };
return true;
}
}