From 41ca094e21fe21b64016df251e3c0e38afeb44fd Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Sun, 30 Mar 2025 06:59:04 +0900 Subject: [PATCH] Init --- Directory.Packages.props | 1 + src/Files.App.CsWin32/ComPtr`1.cs | 5 +- .../Files.App.CsWin32.csproj | 1 + .../IStorageProviderQuotaUI.cs | 24 ++---- .../IStorageProviderStatusUI.cs | 24 ++---- .../IStorageProviderStatusUISource.cs | 24 ++---- .../IStorageProviderStatusUISourceFactory.cs | 24 ++---- src/Files.App.CsWin32/ManualGuid.cs | 75 +++++++++++++++++++ .../Storage/StorageTrashBinService.cs | 15 +--- .../Services/Windows/WindowsDialogService.cs | 30 +------- .../Windows/WindowsRecentItemsService.cs | 14 +--- .../Windows/WindowsWallpaperService.cs | 4 +- src/Files.App/Utils/Shell/LaunchHelper.cs | 2 +- .../Utils/Storage/Helpers/SyncRootHelpers.cs | 3 +- 14 files changed, 115 insertions(+), 131 deletions(-) create mode 100644 src/Files.App.CsWin32/ManualGuid.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 81af77f22b58..806ae6ebe879 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -56,5 +56,6 @@ + \ No newline at end of file diff --git a/src/Files.App.CsWin32/ComPtr`1.cs b/src/Files.App.CsWin32/ComPtr`1.cs index d9ec881127dc..a1eea0ed52f6 100644 --- a/src/Files.App.CsWin32/ComPtr`1.cs +++ b/src/Files.App.CsWin32/ComPtr`1.cs @@ -56,10 +56,9 @@ public readonly ComPtr As() where U : unmanaged, IComIID } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly HRESULT CoCreateInstance(CLSCTX dwClsContext = CLSCTX.CLSCTX_LOCAL_SERVER) + public readonly HRESULT CoCreateInstance(Guid* rclsid, IUnknown* pUnkOuter = null, CLSCTX dwClsContext = CLSCTX.CLSCTX_LOCAL_SERVER) { - Guid iid = typeof(T).GUID, clsid = typeof(U).GUID; - return PInvoke.CoCreateInstance(&clsid, null, dwClsContext, &iid, (void**)this.GetAddressOf()); + return PInvoke.CoCreateInstance(rclsid, pUnkOuter, dwClsContext, (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in T.Guid)), (void**)this.GetAddressOf()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/Files.App.CsWin32/Files.App.CsWin32.csproj b/src/Files.App.CsWin32/Files.App.CsWin32.csproj index d0814957aeba..e4ce900e550d 100644 --- a/src/Files.App.CsWin32/Files.App.CsWin32.csproj +++ b/src/Files.App.CsWin32/Files.App.CsWin32.csproj @@ -13,6 +13,7 @@ + diff --git a/src/Files.App.CsWin32/IStorageProviderQuotaUI.cs b/src/Files.App.CsWin32/IStorageProviderQuotaUI.cs index 3e28cfcabded..2a69457239c0 100644 --- a/src/Files.App.CsWin32/IStorageProviderQuotaUI.cs +++ b/src/Files.App.CsWin32/IStorageProviderQuotaUI.cs @@ -9,9 +9,11 @@ namespace Windows.Win32.System.WinRT { - public unsafe struct IStorageProviderQuotaUI : IComIID + public unsafe partial struct IStorageProviderQuotaUI : IComIID { +#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' private void** lpVtbl; +#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' [MethodImpl(MethodImplOptions.AggressiveInlining)] public HRESULT GetQuotaTotalInBytes(ulong* value) @@ -25,23 +27,7 @@ public HRESULT GetQuotaUsedInBytes(ulong* value) return ((delegate* unmanaged[Stdcall])(lpVtbl[8]))((IStorageProviderQuotaUI*)Unsafe.AsPointer(ref this), value); } - public static ref readonly Guid Guid - { - get - { - // BA6295C3-312E-544F-9FD5-1F81B21F3649 - ReadOnlySpan data = - [ - 0xC3, 0x95, 0x62, 0xBA, - 0x2E, 0x31, - 0x4F, 0x54, - 0x9F, 0xD5, - 0x1F, 0x81, 0xB2, 0x1F, 0x36, 0x49 - ]; - - Debug.Assert(data.Length == sizeof(Guid)); - return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); - } - } + [GuidRVAGen.Guid("BA6295C3-312E-544F-9FD5-1F81B21F3649")] + public static partial ref readonly Guid Guid { get; } } } diff --git a/src/Files.App.CsWin32/IStorageProviderStatusUI.cs b/src/Files.App.CsWin32/IStorageProviderStatusUI.cs index ab7bdcc050d4..b49c1f210d68 100644 --- a/src/Files.App.CsWin32/IStorageProviderStatusUI.cs +++ b/src/Files.App.CsWin32/IStorageProviderStatusUI.cs @@ -9,9 +9,11 @@ namespace Windows.Win32.System.WinRT { - public unsafe struct IStorageProviderStatusUI : IComIID + public unsafe partial struct IStorageProviderStatusUI : IComIID { +#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' private void** lpVtbl; +#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' [MethodImpl(MethodImplOptions.AggressiveInlining)] public HRESULT GetQuotaUI(IStorageProviderQuotaUI** result) @@ -19,23 +21,7 @@ public HRESULT GetQuotaUI(IStorageProviderQuotaUI** result) return ((delegate* unmanaged[Stdcall])lpVtbl[14])((IStorageProviderStatusUI*)Unsafe.AsPointer(ref this), result); } - public static ref readonly Guid Guid - { - get - { - // d6b6a758-198d-5b80-977f-5ff73da33118 - ReadOnlySpan data = - [ - 0x58, 0xa7, 0xb6, 0xd6, - 0x8d, 0x19, - 0x80, 0x5b, - 0x97, 0x7f, - 0x5f, 0xf7, 0x3d, 0xa3, 0x31, 0x18 - ]; - - Debug.Assert(data.Length == sizeof(Guid)); - return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); - } - } + [GuidRVAGen.Guid("D6B6A758-198D-5B80-977F-5FF73DA33118")] + public static partial ref readonly Guid Guid { get; } } } diff --git a/src/Files.App.CsWin32/IStorageProviderStatusUISource.cs b/src/Files.App.CsWin32/IStorageProviderStatusUISource.cs index b7d80b4efb8f..6e7365614e47 100644 --- a/src/Files.App.CsWin32/IStorageProviderStatusUISource.cs +++ b/src/Files.App.CsWin32/IStorageProviderStatusUISource.cs @@ -9,9 +9,11 @@ namespace Windows.Win32.System.WinRT { - public unsafe struct IStorageProviderStatusUISource : IComIID + public unsafe partial struct IStorageProviderStatusUISource : IComIID { +#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' private void** lpVtbl; +#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' [MethodImpl(MethodImplOptions.AggressiveInlining)] public HRESULT GetStatusUI(IStorageProviderStatusUI** result) @@ -19,23 +21,7 @@ public HRESULT GetStatusUI(IStorageProviderStatusUI** result) return ((delegate* unmanaged[Stdcall])lpVtbl[6])((IStorageProviderStatusUISource*)Unsafe.AsPointer(ref this), result); } - public static ref readonly Guid Guid - { - get - { - // A306C249-3D66-5E70-9007-E43DF96051FF - ReadOnlySpan data = - [ - 0x49, 0xc2, 0x06, 0xa3, - 0x66, 0x3d, - 0x70, 0x5e, - 0x90, 0x07, - 0xe4, 0x3d, 0xf9, 0x60, 0x51, 0xff - ]; - - Debug.Assert(data.Length == sizeof(Guid)); - return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); - } - } + [GuidRVAGen.Guid("A306C249-3D66-5E70-9007-E43DF96051FF")] + public static partial ref readonly Guid Guid { get; } } } diff --git a/src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs b/src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs index 4927fa32577e..75d4491ea31e 100644 --- a/src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs +++ b/src/Files.App.CsWin32/IStorageProviderStatusUISourceFactory.cs @@ -9,9 +9,11 @@ namespace Windows.Win32.System.WinRT { - public unsafe struct IStorageProviderStatusUISourceFactory : IComIID + public unsafe partial struct IStorageProviderStatusUISourceFactory : IComIID { +#pragma warning disable CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' private void** lpVtbl; +#pragma warning restore CS0649 // Field 'field' is never assigned to, and will always have its default value 'value' [MethodImpl(MethodImplOptions.AggressiveInlining)] public HRESULT GetStatusUISource(nint syncRootId, IStorageProviderStatusUISource** result) @@ -19,23 +21,7 @@ public HRESULT GetStatusUISource(nint syncRootId, IStorageProviderStatusUISource return ((delegate* unmanaged[Stdcall])lpVtbl[6])((IStorageProviderStatusUISourceFactory*)Unsafe.AsPointer(ref this), syncRootId, result); } - public static ref readonly Guid Guid - { - get - { - // 12E46B74-4E5A-58D1-A62F-0376E8EE7DD8 - ReadOnlySpan data = - [ - 0x74, 0x6b, 0xe4, 0x12, - 0x5a, 0x4e, - 0xd1, 0x58, - 0xa6, 0x2f, - 0x03, 0x76, 0xe8, 0xee, 0x7d, 0xd8 - ]; - - Debug.Assert(data.Length == sizeof(Guid)); - return ref Unsafe.As(ref MemoryMarshal.GetReference(data)); - } - } + [GuidRVAGen.Guid("12E46B74-4E5A-58D1-A62F-0376E8EE7DD8")] + public static partial ref readonly Guid Guid { get; } } } diff --git a/src/Files.App.CsWin32/ManualGuid.cs b/src/Files.App.CsWin32/ManualGuid.cs new file mode 100644 index 000000000000..4a013b61b79c --- /dev/null +++ b/src/Files.App.CsWin32/ManualGuid.cs @@ -0,0 +1,75 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using System; +using System.Runtime.CompilerServices; +using Windows.Win32.System.WinRT; + +namespace Windows.Win32 +{ + public static unsafe partial class IID + { + public static Guid* IID_IStorageProviderStatusUISourceFactory + => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IStorageProviderStatusUISourceFactory.Guid)); + + [GuidRVAGen.Guid("000214E4-0000-0000-C000-000000000046")] + public static partial Guid* IID_IContextMenu { get; } + + [GuidRVAGen.Guid("70629033-E363-4A28-A567-0DB78006E6D7")] + public static partial Guid* IID_IEnumShellItems { get; } + + [GuidRVAGen.Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE")] + public static partial Guid* IID_IShellItem { get; } + + [GuidRVAGen.Guid("7E9FB0D3-919F-4307-AB2E-9B1860310C93")] + public static partial Guid* IID_IShellItem2 { get; } + + [GuidRVAGen.Guid("947AAB5F-0A5C-4C13-B4D6-4BF7836FC9F8")] + public static partial Guid* IID_IFileOperation { get; } + + [GuidRVAGen.Guid("D57C7288-D4AD-4768-BE02-9D969532D960")] + public static partial Guid* IID_IFileOpenDialog { get; } + + [GuidRVAGen.Guid("84BCCD23-5FDE-4CDB-AEA4-AF64B83D78AB")] + public static partial Guid* IID_IFileSaveDialog { get; } + + [GuidRVAGen.Guid("B92B56A9-8B55-4E14-9A89-0199BBB6F93B")] + public static partial Guid* IID_IDesktopWallpaper { get; } + + [GuidRVAGen.Guid("2E941141-7F97-4756-BA1D-9DECDE894A3D")] + public static partial Guid* IID_IApplicationActivationManager { get; } + } + + public static unsafe partial class CLSID + { + [GuidRVAGen.Guid("3AD05575-8857-4850-9277-11B85BDB8E09")] + public static partial Guid* CLSID_FileOperation { get; } + + [GuidRVAGen.Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] + public static partial Guid* CLSID_FileOpenDialog { get; } + + [GuidRVAGen.Guid("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B")] + public static partial Guid* CLSID_FileSaveDialog { get; } + + [GuidRVAGen.Guid("C2CF3110-460E-4FC1-B9D0-8A1C0C9CC4BD")] + public static partial Guid* CLSID_DesktopWallpaper { get; } + + [GuidRVAGen.Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")] + public static partial Guid* CLSID_ApplicationActivationManager { get; } + } + + public static unsafe partial class BHID + { + [GuidRVAGen.Guid("3981E225-F559-11D3-8E3A-00C04F6837D5")] + public static partial Guid* BHID_SFUIObject { get; } + + [GuidRVAGen.Guid("94F60519-2850-4924-AA5A-D15E84868039")] + public static partial Guid* BHID_EnumItems { get; } + } + + public static unsafe partial class FOLDERID + { + [GuidRVAGen.Guid("B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC")] + public static partial Guid* FOLDERID_RecycleBinFolder { get; } + } +} diff --git a/src/Files.App/Services/Storage/StorageTrashBinService.cs b/src/Files.App/Services/Storage/StorageTrashBinService.cs index 78857500bafd..ea1a5eb17531 100644 --- a/src/Files.App/Services/Storage/StorageTrashBinService.cs +++ b/src/Files.App/Services/Storage/StorageTrashBinService.cs @@ -102,21 +102,15 @@ private unsafe bool RestoreAllTrashesInternal() { // Get IShellItem for Recycle Bin folder using ComPtr pRecycleBinFolderShellItem = default; - var recycleBinFolderId = PInvoke.FOLDERID_RecycleBinFolder; - var shellItemGuid = typeof(IShellItem).GUID; - HRESULT hr = PInvoke.SHGetKnownFolderItem(&recycleBinFolderId, KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, HANDLE.Null, &shellItemGuid, (void**)pRecycleBinFolderShellItem.GetAddressOf()); + HRESULT hr = PInvoke.SHGetKnownFolderItem(FOLDERID.FOLDERID_RecycleBinFolder, KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT, HANDLE.Null, IID.IID_IShellItem, (void**)pRecycleBinFolderShellItem.GetAddressOf()); // Get IEnumShellItems for Recycle Bin folder using ComPtr pEnumShellItems = default; - Guid enumShellItemGuid = typeof(IEnumShellItems).GUID; - var enumItemsBHID = PInvoke.BHID_EnumItems; - hr = pRecycleBinFolderShellItem.Get()->BindToHandler(null, &enumItemsBHID, &enumShellItemGuid, (void**)pEnumShellItems.GetAddressOf()); + hr = pRecycleBinFolderShellItem.Get()->BindToHandler(null, BHID.BHID_EnumItems, IID.IID_IEnumShellItems, (void**)pEnumShellItems.GetAddressOf()); // Initialize how to perform the operation using ComPtr pFileOperation = default; - var fileOperationIid = typeof(IFileOperation).GUID; - var fileOperationInstanceIid = typeof(FileOperation).GUID; - hr = PInvoke.CoCreateInstance(&fileOperationInstanceIid, null, CLSCTX.CLSCTX_LOCAL_SERVER, &fileOperationIid, (void**)pFileOperation.GetAddressOf()); + hr = PInvoke.CoCreateInstance(CLSID.CLSID_FileOperation, null, CLSCTX.CLSCTX_LOCAL_SERVER, IID.IID_IFileOperation, (void**)pFileOperation.GetAddressOf()); hr = pFileOperation.Get()->SetOperationFlags(FILEOPERATION_FLAGS.FOF_NO_UI); hr = pFileOperation.Get()->SetOwnerWindow(new(MainWindow.Instance.WindowHandle)); @@ -125,8 +119,7 @@ private unsafe bool RestoreAllTrashesInternal() { // Get the original path using ComPtr pShellItem2 = default; - var shellItem2Iid = typeof(IShellItem2).GUID; - hr = pShellItem.Get()->QueryInterface(&shellItem2Iid, (void**)pShellItem2.GetAddressOf()); + hr = pShellItem.Get()->QueryInterface(IID.IID_IShellItem2, (void**)pShellItem2.GetAddressOf()); hr = PInvoke.PSGetPropertyKeyFromName("System.Recycle.DeletedFrom", out var originalPathPropertyKey); hr = pShellItem2.Get()->GetString(originalPathPropertyKey, out var szOriginalPath); diff --git a/src/Files.App/Services/Windows/WindowsDialogService.cs b/src/Files.App/Services/Windows/WindowsDialogService.cs index b143371934a8..0595b20ce3ad 100644 --- a/src/Files.App/Services/Windows/WindowsDialogService.cs +++ b/src/Files.App/Services/Windows/WindowsDialogService.cs @@ -23,17 +23,7 @@ public unsafe bool Open_FileOpenDialog(nint hWnd, bool pickFoldersOnly, string[] try { using ComPtr pDialog = default; - var dialogInstanceIid = typeof(FileOpenDialog).GUID; - var dialogIid = typeof(IFileOpenDialog).GUID; - - // Get a new instance of the dialog - HRESULT hr = PInvoke.CoCreateInstance( - &dialogInstanceIid, - null, - CLSCTX.CLSCTX_INPROC_SERVER, - &dialogIid, - (void**)pDialog.GetAddressOf()) - .ThrowOnFailure(); + HRESULT hr = pDialog.CoCreateInstance(CLSID.CLSID_FileOpenDialog, null, CLSCTX.CLSCTX_INPROC_SERVER); if (filters.Length is not 0 && filters.Length % 2 is 0) { @@ -56,13 +46,12 @@ public unsafe bool Open_FileOpenDialog(nint hWnd, bool pickFoldersOnly, string[] // Get the default shell folder (My Computer) using ComPtr pDefaultFolderShellItem = default; - var shellItemIid = typeof(IShellItem).GUID; fixed (char* pszDefaultFolderPath = Environment.GetFolderPath(defaultFolder)) { hr = PInvoke.SHCreateItemFromParsingName( pszDefaultFolderPath, null, - &shellItemIid, + IID.IID_IShellItem, (void**)pDefaultFolderShellItem.GetAddressOf()) .ThrowOnFailure(); } @@ -104,17 +93,7 @@ public unsafe bool Open_FileSaveDialog(nint hWnd, bool pickFoldersOnly, string[] try { using ComPtr pDialog = default; - var dialogInstanceIid = typeof(FileSaveDialog).GUID; - var dialogIid = typeof(IFileSaveDialog).GUID; - - // Get a new instance of the dialog - HRESULT hr = PInvoke.CoCreateInstance( - &dialogInstanceIid, - null, - CLSCTX.CLSCTX_INPROC_SERVER, - &dialogIid, - (void**)pDialog.GetAddressOf()) - .ThrowOnFailure(); + HRESULT hr = pDialog.CoCreateInstance(CLSID.CLSID_FileSaveDialog, null, CLSCTX.CLSCTX_INPROC_SERVER); if (filters.Length is not 0 && filters.Length % 2 is 0) { @@ -137,13 +116,12 @@ public unsafe bool Open_FileSaveDialog(nint hWnd, bool pickFoldersOnly, string[] // Get the default shell folder (My Computer) using ComPtr pDefaultFolderShellItem = default; - var shellItemIid = typeof(IShellItem).GUID; fixed (char* pszDefaultFolderPath = Environment.GetFolderPath(defaultFolder)) { hr = PInvoke.SHCreateItemFromParsingName( pszDefaultFolderPath, null, - &shellItemIid, + IID.IID_IShellItem, (void**)pDefaultFolderShellItem.GetAddressOf()) .ThrowOnFailure(); } diff --git a/src/Files.App/Services/Windows/WindowsRecentItemsService.cs b/src/Files.App/Services/Windows/WindowsRecentItemsService.cs index d8246e3360a3..ea604e417c50 100644 --- a/src/Files.App/Services/Windows/WindowsRecentItemsService.cs +++ b/src/Files.App/Services/Windows/WindowsRecentItemsService.cs @@ -115,10 +115,8 @@ public unsafe bool Remove(RecentItem item) { try { - var bhid = PInvoke.BHID_SFUIObject; - var contextMenuIid = typeof(IContextMenu).GUID; using ComPtr pContextMenu = default; - HRESULT hr = item.ShellItem.Get()->BindToHandler(null, &bhid, &contextMenuIid, (void**)pContextMenu.GetAddressOf()); + HRESULT hr = item.ShellItem.Get()->BindToHandler(null, BHID.BHID_SFUIObject, IID.IID_IContextMenu, (void**)pContextMenu.GetAddressOf()); HMENU hMenu = PInvoke.CreatePopupMenu(); hr = pContextMenu.Get()->QueryContextMenu(hMenu, 0, 1, 0x7FFF, PInvoke.CMF_OPTIMIZEFORINVOKE); @@ -191,16 +189,13 @@ private unsafe bool UpdateRecentItems(bool isFolder) : "Shell:::{679F85CB-0220-4080-B29B-5540CC05AAB6}"; // Quick Access folder (recent files) // Get IShellItem of the shell folder - var shellItemIid = typeof(IShellItem).GUID; using ComPtr pFolderShellItem = default; fixed (char* pszFolderShellPath = szFolderShellPath) - hr = PInvoke.SHCreateItemFromParsingName(pszFolderShellPath, null, &shellItemIid, (void**)pFolderShellItem.GetAddressOf()); + hr = PInvoke.SHCreateItemFromParsingName(pszFolderShellPath, null, IID.IID_IShellItem, (void**)pFolderShellItem.GetAddressOf()); // Get IEnumShellItems of the quick access shell folder - var enumItemsBHID = PInvoke.BHID_EnumItems; - Guid enumShellItemIid = typeof(IEnumShellItems).GUID; using ComPtr pEnumShellItems = default; - hr = pFolderShellItem.Get()->BindToHandler(null, &enumItemsBHID, &enumShellItemIid, (void**)pEnumShellItems.GetAddressOf()); + hr = pFolderShellItem.Get()->BindToHandler(null, BHID.BHID_EnumItems, IID.IID_IEnumShellItems, (void**)pEnumShellItems.GetAddressOf()); // Enumerate recent items and populate the list int index = 0; @@ -233,9 +228,8 @@ private unsafe bool UpdateRecentItems(bool isFolder) fileName = string.IsNullOrEmpty(fileNameWithoutExtension) ? SystemIO.Path.GetFileName(fileName) : fileNameWithoutExtension; // Get the date last modified - var shellItem2Iid = typeof(IShellItem2).GUID; using ComPtr pShellItem2 = default; - hr = pShellItem.Get()->QueryInterface(&shellItem2Iid, (void**)pShellItem2.GetAddressOf()); + hr = pShellItem.Get()->QueryInterface(IID.IID_IShellItem2, (void**)pShellItem2.GetAddressOf()); hr = PInvoke.PSGetPropertyKeyFromName("System.DateModified", out var propertyKey); hr = pShellItem2.Get()->GetString(propertyKey, out var szPropertyValue); if (DateTime.TryParse(szPropertyValue.ToString(), out var lastModified)) diff --git a/src/Files.App/Services/Windows/WindowsWallpaperService.cs b/src/Files.App/Services/Windows/WindowsWallpaperService.cs index 590aa7e1c9ba..20d57cd5c271 100644 --- a/src/Files.App/Services/Windows/WindowsWallpaperService.cs +++ b/src/Files.App/Services/Windows/WindowsWallpaperService.cs @@ -19,7 +19,7 @@ public unsafe void SetDesktopWallpaper(string szPath) { // Instantiate IDesktopWallpaper using ComPtr pDesktopWallpaper = default; - HRESULT hr = pDesktopWallpaper.CoCreateInstance().ThrowOnFailure(); + HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper); // Get total count of all available monitors hr = pDesktopWallpaper.Get()->GetMonitorDevicePathCount(out var dwMonitorCount).ThrowOnFailure(); @@ -45,7 +45,7 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths) { // Instantiate IDesktopWallpaper using ComPtr pDesktopWallpaper = default; - HRESULT hr = pDesktopWallpaper.CoCreateInstance().ThrowOnFailure(); + HRESULT hr = pDesktopWallpaper.CoCreateInstance(CLSID.CLSID_DesktopWallpaper); uint dwCount = (uint)aszPaths.Length; ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[aszPaths.Length]; diff --git a/src/Files.App/Utils/Shell/LaunchHelper.cs b/src/Files.App/Utils/Shell/LaunchHelper.cs index 6cab60bd8b05..b00fac7c6380 100644 --- a/src/Files.App/Utils/Shell/LaunchHelper.cs +++ b/src/Files.App/Utils/Shell/LaunchHelper.cs @@ -19,7 +19,7 @@ public static class LaunchHelper public unsafe static void LaunchSettings(string page) { using ComPtr pApplicationActivationManager = default; - pApplicationActivationManager.CoCreateInstance(); + pApplicationActivationManager.CoCreateInstance(CLSID.CLSID_ApplicationActivationManager); pApplicationActivationManager.Get()->ActivateApplication( "windows.immersivecontrolpanel_cw5n1h2txyewy!microsoft.windows.immersivecontrolpanel", diff --git a/src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs b/src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs index e013316b9b34..3bfb6335a568 100644 --- a/src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/SyncRootHelpers.cs @@ -20,7 +20,6 @@ private static unsafe (bool Success, ulong Capacity, ulong Used) GetSyncRootQuot !Guid.TryParse(factoryClsidString, out var factoryClsid)) return (false, 0, 0); - HRESULT hr = default; ulong ulTotalSize = 0ul, ulUsedSize = 0ul; using ComPtr pStorageProviderStatusUISourceFactory = default; using ComPtr pStorageProviderStatusUISource = default; @@ -31,7 +30,7 @@ private static unsafe (bool Success, ulong Capacity, ulong Used) GetSyncRootQuot &factoryClsid, null, CLSCTX.CLSCTX_LOCAL_SERVER, - (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in IStorageProviderStatusUISourceFactory.Guid)), + IID.IID_IStorageProviderStatusUISourceFactory, (void**)pStorageProviderStatusUISourceFactory.GetAddressOf()).ThrowIfFailedOnDebug().Failed) return (false, 0, 0);