Skip to content

Commit b5b9ec1

Browse files
committed
Update 2
1 parent 6843ebf commit b5b9ec1

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

src/Files.App.CsWin32/Windows.Win32.ComPtr.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Runtime.CompilerServices;
66
using Windows.Win32;
7+
using Windows.Win32.Foundation;
78
using Windows.Win32.System.Com;
89

910
namespace Windows.Win32

src/Files.App/Services/Windows/WindowsDialogService.cs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,7 @@ public unsafe bool Open_FileOpenDialog(nint hWnd, bool pickFoldersOnly, string[]
2323
try
2424
{
2525
using ComPtr<IFileOpenDialog> pDialog = default;
26-
var dialogInstanceIid = typeof(FileOpenDialog).GUID;
27-
var dialogIid = typeof(IFileOpenDialog).GUID;
28-
29-
// Get a new instance of the dialog
30-
HRESULT hr = PInvoke.CoCreateInstance(
31-
&dialogInstanceIid,
32-
null,
33-
CLSCTX.CLSCTX_INPROC_SERVER,
34-
&dialogIid,
35-
(void**)pDialog.GetAddressOf())
36-
.ThrowOnFailure();
26+
pDialog.CoCreateInstance<FileOpenDialog>(CLSCTX.CLSCTX_INPROC_SERVER).ThrowOnFailure();
3727

3828
if (filters.Length is not 0 && filters.Length % 2 is 0)
3929
{
@@ -104,17 +94,7 @@ public unsafe bool Open_FileSaveDialog(nint hWnd, bool pickFoldersOnly, string[]
10494
try
10595
{
10696
using ComPtr<IFileSaveDialog> pDialog = default;
107-
var dialogInstanceIid = typeof(FileSaveDialog).GUID;
108-
var dialogIid = typeof(IFileSaveDialog).GUID;
109-
110-
// Get a new instance of the dialog
111-
HRESULT hr = PInvoke.CoCreateInstance(
112-
&dialogInstanceIid,
113-
null,
114-
CLSCTX.CLSCTX_INPROC_SERVER,
115-
&dialogIid,
116-
(void**)pDialog.GetAddressOf())
117-
.ThrowOnFailure();
97+
pDialog.CoCreateInstance<FileSaveDialog>(CLSCTX.CLSCTX_INPROC_SERVER).ThrowOnFailure();
11898

11999
if (filters.Length is not 0 && filters.Length % 2 is 0)
120100
{

0 commit comments

Comments
 (0)