13
13
using Windows . Win32 . Graphics . Dxgi ;
14
14
using Windows . Win32 . Graphics . DirectComposition ;
15
15
using Windows . Win32 . Graphics . Dwm ;
16
- using Windows . Win32 . System . Registry ;
17
16
using Windows . Win32 . UI . Shell ;
18
17
using Windows . Win32 . UI . WindowsAndMessaging ;
19
18
using WinRT ;
@@ -26,10 +25,6 @@ namespace Files.App.ViewModels.Previews
26
25
{
27
26
public sealed class ShellPreviewViewModel : BasePreviewModel
28
27
{
29
- private static readonly Guid IPreviewHandlerIid = new ( 0x8895b1c6 , 0xb41f , 0x4c1c , 0xa5 , 0x62 , 0x0d , 0x56 , 0x42 , 0x50 , 0x83 , 0x6f ) ;
30
- private static readonly Guid QueryAssociationsClsid = new ( 0xa07034fd , 0x6caa , 0x4954 , 0xac , 0x3f , 0x97 , 0xa2 , 0x72 , 0x16 , 0xf9 , 0x8a ) ;
31
- private static readonly Guid IQueryAssociationsIid = new ( 0xc46ca590 , 0x3c3f , 0x11d2 , 0xbe , 0xe6 , 0x00 , 0x00 , 0xf8 , 0x05 , 0xca , 0x57 ) ;
32
-
33
28
PreviewHandler ? currentHandler ;
34
29
ContentExternalOutputLink ? outputLink ;
35
30
WNDCLASSEXW ? wCls ;
@@ -108,9 +103,10 @@ private unsafe LRESULT WndProc(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam
108
103
var clsid = FindPreviewHandlerFor ( Item . FileExtension , hwnd . Value ) ;
109
104
110
105
isOfficePreview = new Guid ? [ ] {
111
- Guid . Parse ( "84F66100-FF7C-4fb4-B0C0-02CD7FB668FE" ) ,
106
+ Guid . Parse ( "84F66100-FF7C-4fb4-B0C0-02CD7FB668FE" ) , //
112
107
Guid . Parse ( "65235197-874B-4A07-BDC5-E65EA825B718" ) ,
113
- Guid . Parse ( "00020827-0000-0000-C000-000000000046" ) } . Contains ( clsid ) ;
108
+ Guid . Parse ( "00020827-0000-0000-C000-000000000046" )
109
+ } . Contains ( clsid ) ;
114
110
115
111
try
116
112
{
@@ -138,21 +134,18 @@ private unsafe LRESULT WndProc(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam
138
134
public unsafe void LoadPreview ( UIElement presenter )
139
135
{
140
136
var parent = MainWindow . Instance . WindowHandle ;
137
+ var hInst = PInvoke . GetModuleHandle ( default ( PWSTR ) ) ;
138
+ var szClassName = $ "{ GetType ( ) . Name } -{ Guid . NewGuid ( ) } ";
139
+ var szWindowName = $ "Preview";
141
140
142
- HINSTANCE hInst = PInvoke . GetModuleHandle ( default ( PWSTR ) ) ;
143
-
144
- string className = $ "{ GetType ( ) . Name } { Guid . NewGuid ( ) } ";
145
-
146
- fixed ( char * pszClassName = className )
141
+ fixed ( char * pszClassName = szClassName )
147
142
{
148
- PWSTR pwszClassName = new ( pszClassName ) ;
149
-
150
143
wCls = new WNDCLASSEXW
151
144
{
152
145
cbSize = ( uint ) Marshal . SizeOf ( typeof ( WNDCLASSEXW ) ) ,
153
146
lpfnWndProc = new ( WndProc ) ,
154
147
hInstance = hInst ,
155
- lpszClassName = pwszClassName ,
148
+ lpszClassName = pszClassName ,
156
149
style = 0 ,
157
150
hIcon = default ,
158
151
hIconSm = default ,
@@ -163,14 +156,12 @@ public unsafe void LoadPreview(UIElement presenter)
163
156
cbWndExtra = 0 ,
164
157
} ;
165
158
166
- fixed ( char * pszWindowName = "Preview" )
159
+ fixed ( char * pszWindowName = szWindowName )
167
160
{
168
- PWSTR lpwszWindowName = new ( pszWindowName ) ;
169
-
170
161
hwnd = PInvoke . CreateWindowEx (
171
162
WINDOW_EX_STYLE . WS_EX_LAYERED | WINDOW_EX_STYLE . WS_EX_COMPOSITED ,
172
163
wCls . Value . lpszClassName ,
173
- lpwszWindowName ,
164
+ pszWindowName ,
174
165
WINDOW_STYLE . WS_CHILD | WINDOW_STYLE . WS_CLIPSIBLINGS | WINDOW_STYLE . WS_VISIBLE ,
175
166
0 , 0 , 0 , 0 ,
176
167
new ( parent ) ,
0 commit comments