Skip to content

Commit 7d9c996

Browse files
committed
Different frameworks support
Added support for .NET Standard 2.0, .NET Standard 2.1 and .NET Core 3.1
1 parent 45b1659 commit 7d9c996

11 files changed

Lines changed: 1089 additions & 1026 deletions

CsWin32/IFIleSaveDialog.cs

Lines changed: 89 additions & 83 deletions
Large diffs are not rendered by default.

CsWin32/IFileDialog.cs

Lines changed: 290 additions & 284 deletions
Large diffs are not rendered by default.

CsWin32/IFileOpenDialog.cs

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,92 @@
11
using System;
22
using System.Runtime.InteropServices;
3-
using System.Runtime.Versioning;
43
using Windows.Win32.Foundation;
54
using Windows.Win32.UI.Shell.Common;
65

7-
namespace Windows.Win32.UI.Shell;
6+
#if NET6_0_OR_GREATER
7+
using System.Runtime.Versioning;
8+
#endif
89

9-
[Guid("D57C7288-D4AD-4768-BE02-9D969532D960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport()]
10-
[SupportedOSPlatform("windows6.0.6000")]
11-
internal interface IFileOpenDialog : IFileDialog
10+
namespace Windows.Win32.UI.Shell
1211
{
13-
new HRESULT Show(HWND hwndOwner);
12+
[Guid("D57C7288-D4AD-4768-BE02-9D969532D960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport()]
13+
#if NET6_0_OR_GREATER
14+
[SupportedOSPlatform("windows6.0.6000")]
15+
#endif
16+
internal interface IFileOpenDialog : IFileDialog
17+
{
18+
new HRESULT Show(HWND hwndOwner);
1419

15-
unsafe new HRESULT SetFileTypes(uint cFileTypes, COMDLG_FILTERSPEC* rgFilterSpec);
20+
unsafe new HRESULT SetFileTypes(uint cFileTypes, COMDLG_FILTERSPEC* rgFilterSpec);
1621

17-
new HRESULT SetFileTypeIndex(uint iFileType);
22+
new HRESULT SetFileTypeIndex(uint iFileType);
1823

19-
new HRESULT GetFileTypeIndex(out uint piFileType);
24+
new HRESULT GetFileTypeIndex(out uint piFileType);
2025

21-
new HRESULT Advise(IFileDialogEvents pfde, out uint pdwCookie);
26+
new HRESULT Advise(IFileDialogEvents pfde, out uint pdwCookie);
2227

23-
new HRESULT Unadvise(uint dwCookie);
28+
new HRESULT Unadvise(uint dwCookie);
2429

25-
new HRESULT SetOptions(FILEOPENDIALOGOPTIONS fos);
30+
new HRESULT SetOptions(FILEOPENDIALOGOPTIONS fos);
2631

27-
unsafe new HRESULT GetOptions(FILEOPENDIALOGOPTIONS* pfos);
32+
unsafe new HRESULT GetOptions(FILEOPENDIALOGOPTIONS* pfos);
2833

29-
new HRESULT SetDefaultFolder(IShellItem psi);
34+
new HRESULT SetDefaultFolder(IShellItem psi);
3035

31-
new HRESULT SetFolder(IShellItem psi);
36+
new HRESULT SetFolder(IShellItem psi);
3237

33-
new HRESULT GetFolder(out IShellItem ppsi);
38+
new HRESULT GetFolder(out IShellItem ppsi);
3439

35-
new HRESULT GetCurrentSelection(out IShellItem ppsi);
40+
new HRESULT GetCurrentSelection(out IShellItem ppsi);
3641

37-
new HRESULT SetFileName(PCWSTR pszName);
42+
new HRESULT SetFileName(PCWSTR pszName);
3843

39-
unsafe new HRESULT GetFileName(PWSTR* pszName);
44+
unsafe new HRESULT GetFileName(PWSTR* pszName);
4045

41-
new HRESULT SetTitle(PCWSTR pszTitle);
46+
new HRESULT SetTitle(PCWSTR pszTitle);
4247

43-
new HRESULT SetOkButtonLabel(PCWSTR pszText);
48+
new HRESULT SetOkButtonLabel(PCWSTR pszText);
4449

45-
new HRESULT SetFileNameLabel(PCWSTR pszLabel);
50+
new HRESULT SetFileNameLabel(PCWSTR pszLabel);
4651

47-
new HRESULT GetResult(out IShellItem ppsi);
52+
new HRESULT GetResult(out IShellItem ppsi);
4853

49-
new HRESULT AddPlace(IShellItem psi, FDAP fdap);
54+
new HRESULT AddPlace(IShellItem psi, FDAP fdap);
5055

51-
new HRESULT SetDefaultExtension(PCWSTR pszDefaultExtension);
56+
new HRESULT SetDefaultExtension(PCWSTR pszDefaultExtension);
5257

53-
new HRESULT Close(HRESULT hr);
58+
new HRESULT Close(HRESULT hr);
5459

55-
unsafe new HRESULT SetClientGuid(Guid* guid);
60+
unsafe new HRESULT SetClientGuid(Guid* guid);
5661

57-
new HRESULT ClearClientData();
62+
new HRESULT ClearClientData();
5863

59-
new HRESULT SetFilter(IShellItemFilter pFilter);
64+
new HRESULT SetFilter(IShellItemFilter pFilter);
6065

61-
/// <summary>Gets the user's choices in a dialog that allows multiple selection.</summary>
62-
/// <param name="ppenum">
63-
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a>**</b> The address of a pointer to an <b>IShellItemArray</b> through which the items selected in the dialog can be accessed.</para>
64-
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getresults#parameters">Read more on docs.microsoft.com</see>.</para>
65-
/// </param>
66-
/// <returns>
67-
/// <para>Type: <b>HRESULT</b> If this method succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
68-
/// </returns>
69-
/// <remarks>
70-
/// <para>This method can be used whether the selection consists of a single item or multiple items. <b>IFileOpenDialog::GetResults</b> can be called after the dialog has closed or during the handling of an IFileDialogEvents::OnFileOk event. Calling this method at any other time will fail.</para>
71-
/// <para><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nf-shobjidl_core-imodalwindow-show">Show</a> must return a success code for a result to be available to <b>IFileOpenDialog::GetResults</b>.</para>
72-
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getresults#">Read more on docs.microsoft.com</see>.</para>
73-
/// </remarks>
74-
HRESULT GetResults(out IShellItemArray ppenum);
66+
/// <summary>Gets the user's choices in a dialog that allows multiple selection.</summary>
67+
/// <param name="ppenum">
68+
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a>**</b> The address of a pointer to an <b>IShellItemArray</b> through which the items selected in the dialog can be accessed.</para>
69+
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getresults#parameters">Read more on docs.microsoft.com</see>.</para>
70+
/// </param>
71+
/// <returns>
72+
/// <para>Type: <b>HRESULT</b> If this method succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
73+
/// </returns>
74+
/// <remarks>
75+
/// <para>This method can be used whether the selection consists of a single item or multiple items. <b>IFileOpenDialog::GetResults</b> can be called after the dialog has closed or during the handling of an IFileDialogEvents::OnFileOk event. Calling this method at any other time will fail.</para>
76+
/// <para><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nf-shobjidl_core-imodalwindow-show">Show</a> must return a success code for a result to be available to <b>IFileOpenDialog::GetResults</b>.</para>
77+
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getresults#">Read more on docs.microsoft.com</see>.</para>
78+
/// </remarks>
79+
HRESULT GetResults(out IShellItemArray ppenum);
7580

76-
/// <summary>Gets the currently selected items in the dialog. These items may be items selected in the view, or text selected in the file name edit box.</summary>
77-
/// <param name="ppsai">
78-
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a>**</b> The address of a pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a> through which the selected items can be accessed.</para>
79-
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getselecteditems#parameters">Read more on docs.microsoft.com</see>.</para>
80-
/// </param>
81-
/// <returns>
82-
/// <para>Type: <b>HRESULT</b> If this method succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
83-
/// </returns>
84-
/// <remarks>This method can be used for single item or multiple item selections. If the user has entered new text in the file name field, this can be a time-consuming operation. When the application calls this method, the application parses the text in the <c>filename</c> field. For example, if this is a network share, the operation could take some time. However, this operation will not block the UI, since the user should able to stop the operation, which will result in <b>IFileOpenDialog::GetSelectedItems</b> returning a failure code).</remarks>
85-
HRESULT GetSelectedItems(out IShellItemArray ppsai);
81+
/// <summary>Gets the currently selected items in the dialog. These items may be items selected in the view, or text selected in the file name edit box.</summary>
82+
/// <param name="ppsai">
83+
/// <para>Type: <b><a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a>**</b> The address of a pointer to an <a href="https://docs.microsoft.com/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishellitemarray">IShellItemArray</a> through which the selected items can be accessed.</para>
84+
/// <para><see href="https://docs.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifileopendialog-getselecteditems#parameters">Read more on docs.microsoft.com</see>.</para>
85+
/// </param>
86+
/// <returns>
87+
/// <para>Type: <b>HRESULT</b> If this method succeeds, it returns <b>S_OK</b>. Otherwise, it returns an <b>HRESULT</b> error code.</para>
88+
/// </returns>
89+
/// <remarks>This method can be used for single item or multiple item selections. If the user has entered new text in the file name field, this can be a time-consuming operation. When the application calls this method, the application parses the text in the <c>filename</c> field. For example, if this is a network share, the operation could take some time. However, this operation will not block the UI, since the user should able to stop the operation, which will result in <b>IFileOpenDialog::GetSelectedItems</b> returning a failure code).</remarks>
90+
HRESULT GetSelectedItems(out IShellItemArray ppsai);
91+
}
8692
}

0 commit comments

Comments
 (0)