Skip to content

Commit 6f5bdee

Browse files
committed
Update
1 parent ce31df3 commit 6f5bdee

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Files.App.Storage/Storables/WindowsStorage/WindowsFolderWatcher.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4-
using OwlCore.Storage;
5-
using System.Collections.Concurrent;
64
using System.Collections.Specialized;
7-
using System.Runtime.CompilerServices;
85
using System.Runtime.InteropServices;
9-
using System.Threading;
106
using Windows.Win32;
117
using Windows.Win32.Foundation;
12-
using Windows.Win32.Graphics.Gdi;
138
using Windows.Win32.System.Com;
149
using Windows.Win32.UI.Shell;
1510
using Windows.Win32.UI.Shell.Common;
1611
using Windows.Win32.UI.WindowsAndMessaging;
1712

1813
namespace Files.App.Storage
1914
{
15+
/// <summary>
16+
/// Represents an implementation of <see cref="IFolderWatcher"/> that uses Windows Shell notifications to watch for changes in a folder.
17+
/// </summary>
2018
public unsafe partial class WindowsFolderWatcher : IFolderWatcher
2119
{
2220
// Fields
2321

24-
private const uint WM_SHFLDRWATCHER = PInvoke.WM_APP | 0x0001U;
22+
private const uint WM_FOLDERWATCHER = PInvoke.WM_APP | 0x0001U;
2523
private readonly WNDPROC _wndProc;
2624

2725
private uint _registrationID = 0U;
@@ -37,12 +35,14 @@ public unsafe partial class WindowsFolderWatcher : IFolderWatcher
3735

3836
// Constructor
3937

38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="WindowsFolderWatcher"/> class.
40+
/// </summary>
41+
/// <param name="folder">Specifies the folder to be monitored for changes.</param>
4042
public WindowsFolderWatcher(WindowsFolder folder)
4143
{
4244
Folder = folder;
4345

44-
HINSTANCE hInst = PInvoke.GetModuleHandle(default(PWSTR));
45-
4646
_wndProc = new(WndProc);
4747
var pfnWndProc = (delegate* unmanaged[Stdcall]<HWND, uint, WPARAM, LPARAM, LRESULT>)Marshal.GetFunctionPointerForDelegate(_wndProc);
4848

@@ -51,11 +51,11 @@ public WindowsFolderWatcher(WindowsFolder folder)
5151
WNDCLASSEXW wndClass = default;
5252
wndClass.cbSize = (uint)sizeof(WNDCLASSEXW);
5353
wndClass.lpfnWndProc = pfnWndProc;
54-
wndClass.hInstance = hInst;
54+
wndClass.hInstance = PInvoke.GetModuleHandle(default(PWSTR)); ;
5555
wndClass.lpszClassName = pszClassName;
5656

5757
PInvoke.RegisterClassEx(&wndClass);
58-
PInvoke.CreateWindowEx(0, pszClassName, null, 0, 0, 0, 0, 0, HWND.HWND_MESSAGE, default, hInst, null);
58+
PInvoke.CreateWindowEx(0, pszClassName, null, 0, 0, 0, 0, 0, HWND.HWND_MESSAGE, default, wndClass.hInstance, null);
5959
}
6060
}
6161

@@ -79,15 +79,15 @@ private unsafe LRESULT WndProc(HWND hWnd, uint uMessage, WPARAM wParam, LPARAM l
7979
hWnd,
8080
SHCNRF_SOURCE.SHCNRF_ShellLevel | SHCNRF_SOURCE.SHCNRF_NewDelivery,
8181
(int)SHCNE_ID.SHCNE_ALLEVENTS,
82-
PInvoke.WM_APP | 1,
82+
WM_FOLDERWATCHER,
8383
1,
8484
&changeNotifyEntry);
8585

8686
if (_registrationID is 0U)
8787
break;
8888
}
8989
break;
90-
case PInvoke.WM_APP | 1:
90+
case WM_FOLDERWATCHER:
9191
{
9292
ITEMIDLIST** ppidl;
9393
int lEvent = 0;

0 commit comments

Comments
 (0)