Skip to content

Commit 24a62c0

Browse files
committed
Use HANDLE instead of SafeFileHandle
1 parent 092caa3 commit 24a62c0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Files.App/App.xaml.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Microsoft.Extensions.Logging;
66
using Microsoft.UI.Xaml;
77
using Microsoft.UI.Xaml.Controls;
8-
using Microsoft.Win32.SafeHandles;
8+
using Windows.Win32.Foundation;
99
using Windows.Win32;
1010
using Microsoft.Windows.AppLifecycle;
1111
using Windows.ApplicationModel;
@@ -225,9 +225,9 @@ private async void Window_Closed(object sender, WindowEventArgs args)
225225
var results = items.Select(x => x.ItemPath).ToList();
226226
System.IO.File.WriteAllLines(OutputPath, results);
227227

228-
SafeFileHandle eventHandle = PInvoke.CreateEvent(null, false, false, "FILEDIALOG");
228+
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, false, false, "FILEDIALOG").DangerousGetHandle();
229229
PInvoke.SetEvent(eventHandle);
230-
eventHandle.Close();
230+
PInvoke.CloseHandle(eventHandle);
231231
}
232232

233233
// Continue running the app on the background

src/Files.App/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public static void OpenShellCommandInExplorer(string shellCommand, int pid)
276276

277277
public static void OpenFileFromTile(string filePath)
278278
{
279-
SafeFileHandle eventHandle = PInvoke.CreateEvent(null, true, false, null);
279+
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, true, false, null).DangerousGetHandle();
280280

281281
Task.Run(() =>
282282
{
@@ -288,7 +288,7 @@ public static void OpenFileFromTile(string filePath)
288288
CWMO_DEFAULT,
289289
INFINITE,
290290
1,
291-
[eventHandle.DangerousGetHandle()],
291+
[eventHandle],
292292
out uint handleIndex);
293293
}
294294
}

0 commit comments

Comments
 (0)