Skip to content

Commit c7ab0f4

Browse files
committed
Use overload
1 parent 62b7d4c commit c7ab0f4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/Files.App/App.xaml.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,15 @@ 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-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, false, false, "FILEDIALOG").DangerousGetHandle();
229-
PInvoke.SetEvent(eventHandle);
230-
PInvoke.CloseHandle(eventHandle);
228+
unsafe
229+
{
230+
fixed (char* fileDialog = "FILEDIALOG")
231+
{
232+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: false, bInitialState: false, lpName: fileDialog);
233+
PInvoke.SetEvent(eventHandle);
234+
PInvoke.CloseHandle(eventHandle);
235+
}
236+
}
231237
}
232238

233239
// Continue running the app on the background

src/Files.App/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ private static async void OnActivated(object? sender, AppActivationArguments arg
250250
/// <remarks>
251251
/// Redirects on another thread and uses a non-blocking wait method to wait for the redirection to complete.
252252
/// </remarks>
253-
public static void RedirectActivationTo(AppInstance keyInstance, AppActivationArguments args)
253+
public static unsafe void RedirectActivationTo(AppInstance keyInstance, AppActivationArguments args)
254254
{
255-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, true, false, null).DangerousGetHandle();
255+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: true, bInitialState: false, lpName: null);
256256

257257
Task.Run(() =>
258258
{
@@ -273,9 +273,9 @@ public static void OpenShellCommandInExplorer(string shellCommand, int pid)
273273
Win32Helper.OpenFolderInExistingShellWindow(shellCommand);
274274
}
275275

276-
public static void OpenFileFromTile(string filePath)
276+
public static unsafe void OpenFileFromTile(string filePath)
277277
{
278-
HANDLE eventHandle = (HANDLE)PInvoke.CreateEvent(null, true, false, null).DangerousGetHandle();
278+
HANDLE eventHandle = PInvoke.CreateEvent(bManualReset: true, bInitialState: false, lpName: null);
279279

280280
Task.Run(() =>
281281
{

0 commit comments

Comments
 (0)