From 644e197df14591fb6a75e0846758da04e2c129ef Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:56:50 +0900 Subject: [PATCH 1/3] Move --- src/Files.App/{Utils/Shell => Helpers/Win32}/Win32API.cs | 0 src/Files.App/Helpers/{ => Win32}/Win32Helpers.cs | 0 src/Files.App/{Utils/Shell => Helpers/Win32}/Win32Shell.cs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename src/Files.App/{Utils/Shell => Helpers/Win32}/Win32API.cs (100%) rename src/Files.App/Helpers/{ => Win32}/Win32Helpers.cs (100%) rename src/Files.App/{Utils/Shell => Helpers/Win32}/Win32Shell.cs (100%) diff --git a/src/Files.App/Utils/Shell/Win32API.cs b/src/Files.App/Helpers/Win32/Win32API.cs similarity index 100% rename from src/Files.App/Utils/Shell/Win32API.cs rename to src/Files.App/Helpers/Win32/Win32API.cs diff --git a/src/Files.App/Helpers/Win32Helpers.cs b/src/Files.App/Helpers/Win32/Win32Helpers.cs similarity index 100% rename from src/Files.App/Helpers/Win32Helpers.cs rename to src/Files.App/Helpers/Win32/Win32Helpers.cs diff --git a/src/Files.App/Utils/Shell/Win32Shell.cs b/src/Files.App/Helpers/Win32/Win32Shell.cs similarity index 100% rename from src/Files.App/Utils/Shell/Win32Shell.cs rename to src/Files.App/Helpers/Win32/Win32Shell.cs From cfa556743e1505598010025526940ab8ac9d8c7d Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 13 Mar 2024 00:04:10 +0900 Subject: [PATCH 2/3] Renamed --- .../Content/Install/InstallFontAction.cs | 2 +- .../Content/Install/InstallInfDriverAction.cs | 2 +- .../Content/Run/RunWithPowershellAction.cs | 2 +- .../Actions/FileSystem/FormatDriveAction.cs | 2 +- .../Actions/Open/OpenInVSCodeAction.cs | 2 +- .../Actions/Open/OpenRepoInVSCodeAction.cs | 2 +- .../Factories/ShellContextFlyoutHelper.cs | 20 ++++++++-------- .../Helpers/Interop/NativeWinApiHelper.cs | 2 +- .../Helpers/Navigation/NavigationHelpers.cs | 16 ++++++------- src/Files.App/Helpers/UI/UIHelpers.cs | 4 ++-- ...Win32Helpers.cs => Win32Helper.Process.cs} | 14 ++++------- .../{Win32Shell.cs => Win32Helper.Shell.cs} | 23 +++++++----------- .../{Win32API.cs => Win32Helper.Storage.cs} | 6 ++--- .../Win32/Win32Helper.WindowManagement.cs | 3 +++ src/Files.App/Program.cs | 2 +- .../Services/NetworkDrivesService.cs | 2 +- src/Files.App/Services/QuickAccessService.cs | 2 +- .../Services/WindowsCompatibilityService.cs | 4 ++-- .../UserControls/Widgets/DrivesWidget.xaml.cs | 2 +- .../Utils/Cloud/CloudDrivesDetector.cs | 10 ++++---- .../Utils/FileTags/FileTagsHelper.cs | 2 +- .../Utils/Global/NetworkDrivesAPI.cs | 4 ++-- src/Files.App/Utils/Library/LibraryManager.cs | 6 ++--- src/Files.App/Utils/RecentItem/RecentItems.cs | 2 +- .../Utils/RecycleBin/RecycleBinHelpers.cs | 6 ++--- src/Files.App/Utils/Shell/ContextMenu.cs | 10 ++++---- src/Files.App/Utils/Shell/LaunchHelper.cs | 16 ++++++------- .../Storage/Helpers/FileSecurityHelpers.cs | 2 +- .../Storage/Helpers/FileThumbnailHelper.cs | 4 ++-- .../Operations/FileOperationsHelpers.cs | 24 +++++++++---------- .../StorageItems/ShellStorageFolder.cs | 2 +- .../Properties/BasePropertiesPage.cs | 2 +- .../Properties/CustomizationViewModel.cs | 10 ++++---- .../Properties/Items/FileProperties.cs | 2 +- .../Properties/Items/FolderProperties.cs | 2 +- .../ViewModels/Settings/AdvancedViewModel.cs | 4 ++-- .../UserControls/AddressToolbarViewModel.cs | 2 +- .../UserControls/SidebarViewModel.cs | 2 +- src/Files.App/Views/HomePage.xaml.cs | 2 +- .../Views/Properties/GeneralPage.xaml.cs | 4 ++-- 40 files changed, 111 insertions(+), 119 deletions(-) rename src/Files.App/Helpers/Win32/{Win32Helpers.cs => Win32Helper.Process.cs} (86%) rename src/Files.App/Helpers/Win32/{Win32Shell.cs => Win32Helper.Shell.cs} (79%) rename src/Files.App/Helpers/Win32/{Win32API.cs => Win32Helper.Storage.cs} (99%) diff --git a/src/Files.App/Actions/Content/Install/InstallFontAction.cs b/src/Files.App/Actions/Content/Install/InstallFontAction.cs index b9ee9a4225a1..6869abb22a09 100644 --- a/src/Files.App/Actions/Content/Install/InstallFontAction.cs +++ b/src/Files.App/Actions/Content/Install/InstallFontAction.cs @@ -34,7 +34,7 @@ public InstallFontAction() public Task ExecuteAsync() { var paths = context.SelectedItems.Select(item => item.ItemPath).ToArray(); - return Win32API.InstallFontsAsync(paths, false); + return Win32Helper.InstallFontsAsync(paths, false); } public void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Content/Install/InstallInfDriverAction.cs b/src/Files.App/Actions/Content/Install/InstallInfDriverAction.cs index da4ab1ddba47..16d928d103d3 100644 --- a/src/Files.App/Actions/Content/Install/InstallInfDriverAction.cs +++ b/src/Files.App/Actions/Content/Install/InstallInfDriverAction.cs @@ -33,7 +33,7 @@ public InstallInfDriverAction() public async Task ExecuteAsync() { - await Task.WhenAll(context.SelectedItems.Select(selectedItem => Win32API.InstallInf(selectedItem.ItemPath))); + await Task.WhenAll(context.SelectedItems.Select(selectedItem => Win32Helper.InstallInf(selectedItem.ItemPath))); } public void Context_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs index a01cd6cece6c..59dc05df35e9 100644 --- a/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs +++ b/src/Files.App/Actions/Content/Run/RunWithPowershellAction.cs @@ -31,7 +31,7 @@ public RunWithPowershellAction() public Task ExecuteAsync() { - return Win32API.RunPowershellCommandAsync($"{context.ShellPage?.SlimContentPage?.SelectedItem?.ItemPath}", false); + return Win32Helper.RunPowershellCommandAsync($"{context.ShellPage?.SlimContentPage?.SelectedItem?.ItemPath}", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/FileSystem/FormatDriveAction.cs b/src/Files.App/Actions/FileSystem/FormatDriveAction.cs index 569cdb05ef66..d0836bfd387f 100644 --- a/src/Files.App/Actions/FileSystem/FormatDriveAction.cs +++ b/src/Files.App/Actions/FileSystem/FormatDriveAction.cs @@ -33,7 +33,7 @@ public FormatDriveAction() public Task ExecuteAsync() { - return Win32API.OpenFormatDriveDialog(context.Folder?.ItemPath ?? string.Empty); + return Win32Helper.OpenFormatDriveDialog(context.Folder?.ItemPath ?? string.Empty); } public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs index e40eead75804..de7acddb9c6f 100644 --- a/src/Files.App/Actions/Open/OpenInVSCodeAction.cs +++ b/src/Files.App/Actions/Open/OpenInVSCodeAction.cs @@ -32,7 +32,7 @@ public OpenInVSCodeAction() public Task ExecuteAsync() { - return Win32API.RunPowershellCommandAsync($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false); + return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage?.FilesystemViewModel.WorkingDirectory}\'", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Actions/Open/OpenRepoInVSCodeAction.cs b/src/Files.App/Actions/Open/OpenRepoInVSCodeAction.cs index c5b185515e31..b49d2ee7339a 100644 --- a/src/Files.App/Actions/Open/OpenRepoInVSCodeAction.cs +++ b/src/Files.App/Actions/Open/OpenRepoInVSCodeAction.cs @@ -33,7 +33,7 @@ public OpenRepoInVSCodeAction() public Task ExecuteAsync() { - return Win32API.RunPowershellCommandAsync($"code \'{_context.ShellPage!.InstanceViewModel.GitRepositoryPath}\'", false); + return Win32Helper.RunPowershellCommandAsync($"code \'{_context.ShellPage!.InstanceViewModel.GitRepositoryPath}\'", false); } private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) diff --git a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs index e909873e8478..1c158a14f0c4 100644 --- a/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs +++ b/src/Files.App/Data/Factories/ShellContextFlyoutHelper.cs @@ -40,11 +40,11 @@ Func FilterMenuItems(bool showOpenMenu) "Windows.ModernShare", "Windows.Share", "setdesktopwallpaper", "eject", "rename", "explore", "openinfiles", "extract", "copyaspath", "undelete", "empty", "format", "rotate90", "rotate270", - Win32API.ExtractStringFromDLL("shell32.dll", 34593), // Add to collection - Win32API.ExtractStringFromDLL("shell32.dll", 5384), // Pin to Start - Win32API.ExtractStringFromDLL("shell32.dll", 5385), // Unpin from Start - Win32API.ExtractStringFromDLL("shell32.dll", 5386), // Pin to taskbar - Win32API.ExtractStringFromDLL("shell32.dll", 5387), // Unpin from taskbar + Win32Helper.ExtractStringFromDLL("shell32.dll", 34593), // Add to collection + Win32Helper.ExtractStringFromDLL("shell32.dll", 5384), // Pin to Start + Win32Helper.ExtractStringFromDLL("shell32.dll", 5385), // Unpin from Start + Win32Helper.ExtractStringFromDLL("shell32.dll", 5386), // Pin to taskbar + Win32Helper.ExtractStringFromDLL("shell32.dll", 5387), // Unpin from taskbar }; bool filterMenuItemsImpl(string menuItem) => !string.IsNullOrEmpty(menuItem) @@ -130,7 +130,7 @@ private static void LoadMenuFlyoutItem( } else if (!string.IsNullOrEmpty(menuFlyoutItem.Label) && menuFlyoutItem.SubItems is not null) { - if (string.Equals(menuFlyoutItem.Label, Win32API.ExtractStringFromDLL("shell32.dll", 30312))) + if (string.Equals(menuFlyoutItem.Label, Win32Helper.ExtractStringFromDLL("shell32.dll", 30312))) menuFlyoutItem.CommandString = "sendto"; var menuLayoutSubItem = new ContextMenuFlyoutItemViewModel() @@ -181,21 +181,21 @@ async Task InvokeShellMenuItemAsync(ContextMenu contextMenu, object? tag) switch (verb) { case "install" when isFont: - await Win32API.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), false); + await Win32Helper.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), false); break; case "installAllUsers" when isFont: - await Win32API.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), true); + await Win32Helper.InstallFontsAsync(contextMenu.ItemsPath.ToArray(), true); break; case "mount": var vhdPath = contextMenu.ItemsPath[0]; - await Win32API.MountVhdDisk(vhdPath); + await Win32Helper.MountVhdDisk(vhdPath); break; case "format": var drivePath = contextMenu.ItemsPath[0]; - await Win32API.OpenFormatDriveDialog(drivePath); + await Win32Helper.OpenFormatDriveDialog(drivePath); break; default: diff --git a/src/Files.App/Helpers/Interop/NativeWinApiHelper.cs b/src/Files.App/Helpers/Interop/NativeWinApiHelper.cs index 3630142b30ce..c302df814bb5 100644 --- a/src/Files.App/Helpers/Interop/NativeWinApiHelper.cs +++ b/src/Files.App/Helpers/Interop/NativeWinApiHelper.cs @@ -257,6 +257,6 @@ public static bool IsHasThreadAccessPropertyPresent } public static Task GetFileAssociationAsync(string filePath) - => Win32API.GetFileAssociationAsync(filePath, true); + => Win32Helper.GetFileAssociationAsync(filePath, true); } } \ No newline at end of file diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index b01b1c9b05e2..e5f89b04dd4a 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -292,7 +292,7 @@ public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, b selectedItems.Count > 1 && selectedItems.All(x => x.PrimaryItemAttribute == StorageItemTypes.File && !x.IsExecutable && !x.IsShortcut)) { - opened = await Win32Helpers.InvokeWin32ComponentAsync(string.Join('|', selectedItems.Select(x => x.ItemPath)), associatedInstance); + opened = await Win32Helper.InvokeWin32ComponentAsync(string.Join('|', selectedItems.Select(x => x.ItemPath)), associatedInstance); } if (opened) @@ -319,7 +319,7 @@ public static async Task OpenItemsWithExecutableAsync(IShellPage associatedInsta return; var arguments = string.Join(" ", items.Select(item => $"\"{item.Path}\"")); - await Win32Helpers.InvokeWin32ComponentAsync(executablePath, associatedInstance, arguments); + await Win32Helper.InvokeWin32ComponentAsync(executablePath, associatedInstance, arguments); } /// @@ -469,7 +469,7 @@ private static async Task OpenDirectory(string path, IShellPag { if (string.IsNullOrEmpty(shortcutInfo.TargetPath)) { - await Win32Helpers.InvokeWin32ComponentAsync(path, associatedInstance); + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance); opened = (FilesystemResult)true; } else @@ -498,7 +498,7 @@ private static async Task OpenDirectory(string path, IShellPag if (opened) await OpenPath(forceOpenInNewTab, UserSettingsService.FoldersSettingsService.OpenFoldersInNewTab, path, associatedInstance, selectItems); else - await Win32Helpers.InvokeWin32ComponentAsync(path, associatedInstance); + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance); } return opened; } @@ -513,7 +513,7 @@ private static async Task OpenFile(string path, IShellPage ass { if (string.IsNullOrEmpty(shortcutInfo.TargetPath)) { - await Win32Helpers.InvokeWin32ComponentAsync(path, associatedInstance, args); + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance, args); } else { @@ -524,13 +524,13 @@ private static async Task OpenFile(string path, IShellPage ass if (childFile?.Item is SystemStorageFile) App.RecentItemsManager.AddToRecentItems(childFile.Path); } - await Win32Helpers.InvokeWin32ComponentAsync(shortcutInfo.TargetPath, associatedInstance, $"{args} {shortcutInfo.Arguments}", shortcutInfo.RunAsAdmin, shortcutInfo.WorkingDirectory); + await Win32Helper.InvokeWin32ComponentAsync(shortcutInfo.TargetPath, associatedInstance, $"{args} {shortcutInfo.Arguments}", shortcutInfo.RunAsAdmin, shortcutInfo.WorkingDirectory); } opened = (FilesystemResult)true; } else if (isHiddenItem) { - await Win32Helpers.InvokeWin32ComponentAsync(path, associatedInstance, args); + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance, args); } else { @@ -630,7 +630,7 @@ private static async Task OpenFile(string path, IShellPage ass } if (!launchSuccess) - await Win32Helpers.InvokeWin32ComponentAsync(path, associatedInstance, args); + await Win32Helper.InvokeWin32ComponentAsync(path, associatedInstance, args); } }); } diff --git a/src/Files.App/Helpers/UI/UIHelpers.cs b/src/Files.App/Helpers/UI/UIHelpers.cs index b4887e47956c..145887fcd8df 100644 --- a/src/Files.App/Helpers/UI/UIHelpers.cs +++ b/src/Files.App/Helpers/UI/UIHelpers.cs @@ -163,7 +163,7 @@ public static IconFileInfo GetSidebarIconResourceInfo(int index) private static IEnumerable LoadSidebarIconResources() { string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll"); - var imageResList = Win32API.ExtractSelectedIconsFromDLL(imageres, new List() { + var imageResList = Win32Helper.ExtractSelectedIconsFromDLL(imageres, new List() { Constants.ImageRes.RecycleBin, Constants.ImageRes.NetworkDrives, Constants.ImageRes.Libraries, @@ -179,7 +179,7 @@ private static IEnumerable LoadSidebarIconResources() private static IconFileInfo LoadShieldIconResource() { string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll"); - var imageResList = Win32API.ExtractSelectedIconsFromDLL(imageres, new List() { + var imageResList = Win32Helper.ExtractSelectedIconsFromDLL(imageres, new List() { Constants.ImageRes.ShieldIcon }, 16); diff --git a/src/Files.App/Helpers/Win32/Win32Helpers.cs b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs similarity index 86% rename from src/Files.App/Helpers/Win32/Win32Helpers.cs rename to src/Files.App/Helpers/Win32/Win32Helper.Process.cs index 6e21bf74fd06..d0a79258cc30 100644 --- a/src/Files.App/Helpers/Win32/Win32Helpers.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.Process.cs @@ -1,16 +1,12 @@ // Copyright (c) 2024 Files Community // Licensed under the MIT License. See the LICENSE. -using Files.App.Utils.Shell; -using Files.Shared.Extensions; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; - namespace Files.App.Helpers { - public static class Win32Helpers + /// + /// Provides static helper for Win32. + /// + public static partial class Win32Helper { public static async Task InvokeWin32ComponentAsync(string applicationPath, IShellPage associatedInstance, string arguments = null, bool runAsAdmin = false, string workingDirectory = null) { @@ -42,4 +38,4 @@ public static async Task InvokeWin32ComponentsAsync(IEnumerable ap } } } -} \ No newline at end of file +} diff --git a/src/Files.App/Helpers/Win32/Win32Shell.cs b/src/Files.App/Helpers/Win32/Win32Helper.Shell.cs similarity index 79% rename from src/Files.App/Helpers/Win32/Win32Shell.cs rename to src/Files.App/Helpers/Win32/Win32Helper.Shell.cs index 3dfa034ff7b4..873bd38df45e 100644 --- a/src/Files.App/Helpers/Win32/Win32Shell.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.Shell.cs @@ -6,23 +6,16 @@ using Vanara.PInvoke; using Vanara.Windows.Shell; -namespace Files.App.Utils.Shell +namespace Files.App.Helpers { /// - /// Provides a utility to manage shell folders. + /// Provides static helper for Win32. /// - public class Win32Shell + public static partial class Win32Helper { - private readonly static ShellFolder _controlPanel; + private readonly static ShellFolder _controlPanel = new(Shell32.KNOWNFOLDERID.FOLDERID_ControlPanelFolder); - private readonly static ShellFolder _controlPanelCategoryView; - - static Win32Shell() - { - _controlPanel = new ShellFolder(Shell32.KNOWNFOLDERID.FOLDERID_ControlPanelFolder); - - _controlPanelCategoryView = new ShellFolder("::{26EE0668-A00A-44D7-9371-BEB064C98683}"); - } + private readonly static ShellFolder _controlPanelCategoryView = new("::{26EE0668-A00A-44D7-9371-BEB064C98683}"); public static async Task<(ShellFileItem Folder, List Enumerate)> GetShellFolderAsync(string path, string action, int from, int count, params string[] properties) { @@ -31,7 +24,7 @@ static Win32Shell() path = $"shell:{path}"; } - return await Win32API.StartSTATask(() => + return await Win32Helper.StartSTATask(() => { var flc = new List(); var folder = (ShellFileItem)null; @@ -88,10 +81,10 @@ static Win32Shell() public static (bool HasRecycleBin, long NumItems, long BinSize) QueryRecycleBin(string drive = "") { - Win32API.SHQUERYRBINFO queryBinInfo = new Win32API.SHQUERYRBINFO(); + Win32Helper.SHQUERYRBINFO queryBinInfo = new Win32Helper.SHQUERYRBINFO(); queryBinInfo.cbSize = Marshal.SizeOf(queryBinInfo); - var res = Win32API.SHQueryRecycleBin(drive, ref queryBinInfo); + var res = Win32Helper.SHQueryRecycleBin(drive, ref queryBinInfo); if (res == HRESULT.S_OK) { var numItems = queryBinInfo.i64NumItems; diff --git a/src/Files.App/Helpers/Win32/Win32API.cs b/src/Files.App/Helpers/Win32/Win32Helper.Storage.cs similarity index 99% rename from src/Files.App/Helpers/Win32/Win32API.cs rename to src/Files.App/Helpers/Win32/Win32Helper.Storage.cs index 6687910192d5..012ad00aa65f 100644 --- a/src/Files.App/Helpers/Win32/Win32API.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.Storage.cs @@ -12,12 +12,12 @@ using Vanara.PInvoke; using Windows.System; -namespace Files.App.Utils.Shell +namespace Files.App.Helpers { /// - /// Provides static helper for general Win32API. + /// Provides static helper for Win32. /// - internal class Win32API + public static partial class Win32Helper { public static Task StartSTATask(Func func) { diff --git a/src/Files.App/Helpers/Win32/Win32Helper.WindowManagement.cs b/src/Files.App/Helpers/Win32/Win32Helper.WindowManagement.cs index 63c7b335554d..5264c3c1e021 100644 --- a/src/Files.App/Helpers/Win32/Win32Helper.WindowManagement.cs +++ b/src/Files.App/Helpers/Win32/Win32Helper.WindowManagement.cs @@ -6,6 +6,9 @@ namespace Files.App.Helpers { + /// + /// Provides static helper for Win32. + /// public static partial class Win32Helper { /// diff --git a/src/Files.App/Program.cs b/src/Files.App/Program.cs index 26a7ae019863..715927f0b953 100644 --- a/src/Files.App/Program.cs +++ b/src/Files.App/Program.cs @@ -209,7 +209,7 @@ public static void RedirectActivationTo(AppInstance keyInstance, AppActivationAr public static void OpenShellCommandInExplorer(string shellCommand, int pid) { - Win32API.OpenFolderInExistingShellWindow(shellCommand); + Win32Helper.OpenFolderInExistingShellWindow(shellCommand); } public static void OpenFileFromTile(string filePath) diff --git a/src/Files.App/Services/NetworkDrivesService.cs b/src/Files.App/Services/NetworkDrivesService.cs index 5e98b558e561..60c608011b90 100644 --- a/src/Files.App/Services/NetworkDrivesService.cs +++ b/src/Files.App/Services/NetworkDrivesService.cs @@ -17,7 +17,7 @@ public bool DisconnectNetworkDrive(ILocatableFolder drive) public async IAsyncEnumerable GetDrivesAsync() { - var networkLocations = await Win32API.StartSTATask(() => + var networkLocations = await Win32Helper.StartSTATask(() => { var locations = new List(); using (var nethood = new ShellFolder(Shell32.KNOWNFOLDERID.FOLDERID_NetHood)) diff --git a/src/Files.App/Services/QuickAccessService.cs b/src/Files.App/Services/QuickAccessService.cs index f2dfb5f9d0fd..1c072b6ab73c 100644 --- a/src/Files.App/Services/QuickAccessService.cs +++ b/src/Files.App/Services/QuickAccessService.cs @@ -12,7 +12,7 @@ internal class QuickAccessService : IQuickAccessService public async Task> GetPinnedFoldersAsync() { - var result = (await Win32Shell.GetShellFolderAsync(guid, "Enumerate", 0, int.MaxValue, "System.Home.IsPinned")).Enumerate + var result = (await Win32Helper.GetShellFolderAsync(guid, "Enumerate", 0, int.MaxValue, "System.Home.IsPinned")).Enumerate .Where(link => link.IsFolder); return result; } diff --git a/src/Files.App/Services/WindowsCompatibilityService.cs b/src/Files.App/Services/WindowsCompatibilityService.cs index 387a10d59482..b77f73633e48 100644 --- a/src/Files.App/Services/WindowsCompatibilityService.cs +++ b/src/Files.App/Services/WindowsCompatibilityService.cs @@ -39,13 +39,13 @@ public bool SetCompatibilityOptionsForPath(string filePath, WindowsCompatibility // Remove old one if new one is valid if (string.IsNullOrEmpty(stringOptions) || stringOptions == "~") { - return Win32API.RunPowershellCommand( + return Win32Helper.RunPowershellCommand( @$"Remove-ItemProperty -Path 'HKCU:\{_registrySubPath}' -Name '{filePath}' | Out-Null", true); } // Set the new one - return Win32API.RunPowershellCommand( + return Win32Helper.RunPowershellCommand( @$"New-ItemProperty -Path 'HKCU:\{_registrySubPath}' -Name '{filePath}' -Value '{options}' -PropertyType String -Force | Out-Null", true); } diff --git a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs index 81791716a55e..b6d3d2945f20 100644 --- a/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs +++ b/src/Files.App/UserControls/Widgets/DrivesWidget.xaml.cs @@ -238,7 +238,7 @@ private async Task EjectDeviceAsync(WidgetDriveCardItem item) private void FormatDrive(WidgetDriveCardItem? item) { - Win32API.OpenFormatDriveDialog(item?.Path ?? string.Empty); + Win32Helper.OpenFormatDriveDialog(item?.Path ?? string.Empty); } private void OpenProperties(WidgetDriveCardItem item) diff --git a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs index b87d40582a0d..f58d8519f441 100644 --- a/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs +++ b/src/Files.App/Utils/Cloud/CloudDrivesDetector.cs @@ -139,7 +139,7 @@ private static Task> DetectGenericCloudDrive() SyncFolder = syncedFolder, IconData = driveID switch { - CloudProviders.ProtonDrive => Win32API.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }).FirstOrDefault()?.IconData, + CloudProviders.ProtonDrive => Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }).FirstOrDefault()?.IconData, _ => null } }); @@ -243,7 +243,7 @@ private static Task> DetectpCloudDrive() if (syncedFolder is not null) { string iconPath = Path.Combine(programFilesFolder, "pCloud Drive", "pCloud.exe"); - var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }, 32).FirstOrDefault(); + var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }, 32).FirstOrDefault(); App.AppModel.PCloudDrivePath = syncedFolder; @@ -266,7 +266,7 @@ private static Task> DetectNutstoreDrive() if (NutstoreKey is not null) { string iconPath = Path.Combine(programFilesFolder, "Nutstore", "Nutstore.exe"); - var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List() { 101 }).FirstOrDefault(); + var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 101 }).FirstOrDefault(); // get every folder under the Nutstore folder in %userprofile% var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Nutstore"); @@ -298,7 +298,7 @@ private static Task> DetectSeadriveDrive() if (SeadriveKey is not null) { string iconPath = Path.Combine(programFilesFolder, "SeaDrive", "bin", "seadrive.exe"); - var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List() { 101 }).FirstOrDefault(); + var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 101 }).FirstOrDefault(); results.Add(new CloudProvider(CloudProviders.Seadrive) { @@ -319,7 +319,7 @@ private static Task> DetectAutodeskDrive() if (AutodeskKey is not null) { string iconPath = Path.Combine(programFilesFolder, "Autodesk", "Desktop Connector", "DesktopConnector.Applications.Tray.exe"); - var iconFile = Win32API.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }).FirstOrDefault(); + var iconFile = Win32Helper.ExtractSelectedIconsFromDLL(iconPath, new List() { 32512 }).FirstOrDefault(); var mainFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "DC"); var autodeskFolders = Directory.GetDirectories(mainFolder, "", SearchOption.AllDirectories); diff --git a/src/Files.App/Utils/FileTags/FileTagsHelper.cs b/src/Files.App/Utils/FileTags/FileTagsHelper.cs index ad5aba7dcc83..aff18d0ba138 100644 --- a/src/Files.App/Utils/FileTags/FileTagsHelper.cs +++ b/src/Files.App/Utils/FileTags/FileTagsHelper.cs @@ -68,7 +68,7 @@ public static void UpdateTagsDb() var dbInstance = GetDbInstance(); foreach (var file in dbInstance.GetAll()) { - var pathFromFrn = Win32API.PathFromFileId(file.Frn ?? 0, file.FilePath); + var pathFromFrn = Win32Helper.PathFromFileId(file.Frn ?? 0, file.FilePath); if (pathFromFrn is not null) { // Frn is valid, update file path diff --git a/src/Files.App/Utils/Global/NetworkDrivesAPI.cs b/src/Files.App/Utils/Global/NetworkDrivesAPI.cs index fa53186d76c4..8f359b7c779f 100644 --- a/src/Files.App/Utils/Global/NetworkDrivesAPI.cs +++ b/src/Files.App/Utils/Global/NetworkDrivesAPI.cs @@ -117,11 +117,11 @@ protected override bool RunDialog(IntPtr hwndOwner) public static Task OpenMapNetworkDriveDialog(long hwnd) { - return Win32API.StartSTATask(() => + return Win32Helper.StartSTATask(() => { using var ncd = new NetworkConnectionDialog { UseMostRecentPath = true }; ncd.HideRestoreConnectionCheckBox = false; - return ncd.ShowDialog(Win32API.Win32Window.FromLong(hwnd)) == System.Windows.Forms.DialogResult.OK; + return ncd.ShowDialog(Win32Helper.Win32Window.FromLong(hwnd)) == System.Windows.Forms.DialogResult.OK; }); } diff --git a/src/Files.App/Utils/Library/LibraryManager.cs b/src/Files.App/Utils/Library/LibraryManager.cs index 02dfae04859d..129299ad0c9b 100644 --- a/src/Files.App/Utils/Library/LibraryManager.cs +++ b/src/Files.App/Utils/Library/LibraryManager.cs @@ -68,7 +68,7 @@ private void InitializeWatcher() /// List of library items public static async Task> ListUserLibraries() { - var libraries = await Win32API.StartSTATask(() => + var libraries = await Win32Helper.StartSTATask(() => { try { @@ -135,7 +135,7 @@ public async Task CreateNewLibrary(string name) if (string.IsNullOrWhiteSpace(name) || !CanCreateLibrary(name).result) return false; - var newLib = new LibraryLocationItem(await Win32API.StartSTATask(() => + var newLib = new LibraryLocationItem(await Win32Helper.StartSTATask(() => { try { @@ -179,7 +179,7 @@ public async Task UpdateLibrary(string libraryPath, string // Nothing to update return null; - var item = await Win32API.StartSTATask(() => + var item = await Win32Helper.StartSTATask(() => { try { diff --git a/src/Files.App/Utils/RecentItem/RecentItems.cs b/src/Files.App/Utils/RecentItem/RecentItems.cs index 821276c249c7..72e98661cf87 100644 --- a/src/Files.App/Utils/RecentItem/RecentItems.cs +++ b/src/Files.App/Utils/RecentItem/RecentItems.cs @@ -103,7 +103,7 @@ public async Task UpdateRecentFoldersAsync() /// public async Task> ListRecentFilesAsync() { - return (await Win32Shell.GetShellFolderAsync(QuickAccessGuid, "Enumerate", 0, int.MaxValue)).Enumerate + return (await Win32Helper.GetShellFolderAsync(QuickAccessGuid, "Enumerate", 0, int.MaxValue)).Enumerate .Where(link => !link.IsFolder) .Select(link => new RecentItem(link)).ToList(); } diff --git a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs index 34b438d9f460..9d1129418e79 100644 --- a/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs +++ b/src/Files.App/Utils/RecycleBin/RecycleBinHelpers.cs @@ -19,12 +19,12 @@ public static class RecycleBinHelpers public static async Task> EnumerateRecycleBin() { - return (await Win32Shell.GetShellFolderAsync(Constants.UserEnvironmentPaths.RecycleBinPath, "Enumerate", 0, int.MaxValue)).Enumerate; + return (await Win32Helper.GetShellFolderAsync(Constants.UserEnvironmentPaths.RecycleBinPath, "Enumerate", 0, int.MaxValue)).Enumerate; } public static ulong GetSize() { - return (ulong)Win32Shell.QueryRecycleBin().BinSize; + return (ulong)Win32Helper.QueryRecycleBin().BinSize; } public static async Task IsRecycleBinItem(IStorageItem item) @@ -151,7 +151,7 @@ public static async Task HasRecycleBin(string? path) public static bool RecycleBinHasItems() { - return Win32Shell.QueryRecycleBin().NumItems > 0; + return Win32Helper.QueryRecycleBin().NumItems > 0; } public static async Task RestoreItemAsync(IShellPage associatedInstance) diff --git a/src/Files.App/Utils/Shell/ContextMenu.cs b/src/Files.App/Utils/Shell/ContextMenu.cs index f75c287e4a83..3d96a6da428b 100644 --- a/src/Files.App/Utils/Shell/ContextMenu.cs +++ b/src/Files.App/Utils/Shell/ContextMenu.cs @@ -60,7 +60,7 @@ public async Task InvokeVerb(string? verb) try { - var currentWindows = Win32API.GetDesktopWindows(); + var currentWindows = Win32Helper.GetDesktopWindows(); var pici = new Shell32.CMINVOKECOMMANDINFOEX { @@ -71,7 +71,7 @@ public async Task InvokeVerb(string? verb) pici.cbSize = (uint)Marshal.SizeOf(pici); await _owningThread.PostMethod(() => _cMenu.InvokeCommand(pici)); - Win32API.BringToForeground(currentWindows); + Win32Helper.BringToForeground(currentWindows); return true; } @@ -90,7 +90,7 @@ public async Task InvokeItem(int itemID) try { - var currentWindows = Win32API.GetDesktopWindows(); + var currentWindows = Win32Helper.GetDesktopWindows(); var pici = new Shell32.CMINVOKECOMMANDINFOEX { lpVerb = Macros.MAKEINTRESOURCE(itemID), @@ -100,7 +100,7 @@ public async Task InvokeItem(int itemID) pici.cbSize = (uint)Marshal.SizeOf(pici); await _owningThread.PostMethod(() => _cMenu.InvokeCommand(pici)); - Win32API.BringToForeground(currentWindows); + Win32Helper.BringToForeground(currentWindows); return true; } @@ -232,7 +232,7 @@ private void EnumMenuItems(HMENU hMenu, List menuItemsResu if (menuItemInfo.hbmpItem != HBITMAP.NULL && !Enum.IsDefined(typeof(HBITMAP_HMENU), ((IntPtr)menuItemInfo.hbmpItem).ToInt64())) { - using var bitmap = Win32API.GetBitmapFromHBitmap(menuItemInfo.hbmpItem); + using var bitmap = Win32Helper.GetBitmapFromHBitmap(menuItemInfo.hbmpItem); if (bitmap is not null) { diff --git a/src/Files.App/Utils/Shell/LaunchHelper.cs b/src/Files.App/Utils/Shell/LaunchHelper.cs index 09bd3d13bbfe..4a932c349667 100644 --- a/src/Files.App/Utils/Shell/LaunchHelper.cs +++ b/src/Files.App/Utils/Shell/LaunchHelper.cs @@ -54,12 +54,12 @@ public static Task RunCompatibilityTroubleshooterAsync(string filePath) private static async Task HandleApplicationLaunch(string application, string arguments, string workingDirectory) { - var currentWindows = Win32API.GetDesktopWindows(); + var currentWindows = Win32Helper.GetDesktopWindows(); if (FileExtensionHelpers.IsVhdFile(application)) { // Use PowerShell to mount Vhd Disk as this requires admin rights - return await Win32API.MountVhdDisk(application); + return await Win32Helper.MountVhdDisk(application); } try @@ -109,7 +109,7 @@ private static async Task HandleApplicationLaunch(string application, stri process.StartInfo.WorkingDirectory = string.IsNullOrEmpty(workingDirectory) ? PathNormalization.GetParentDir(application) : workingDirectory; process.Start(); - Win32API.BringToForeground(currentWindows); + Win32Helper.BringToForeground(currentWindows); return true; } @@ -126,7 +126,7 @@ private static async Task HandleApplicationLaunch(string application, stri { process.Start(); - Win32API.BringToForeground(currentWindows); + Win32Helper.BringToForeground(currentWindows); return true; } @@ -134,21 +134,21 @@ private static async Task HandleApplicationLaunch(string application, stri { try { - var opened = await Win32API.StartSTATask(async () => + var opened = await Win32Helper.StartSTATask(async () => { var split = application.Split('|').Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => GetMtpPath(x)); if (split.Count() == 1) { Process.Start(split.First()); - Win32API.BringToForeground(currentWindows); + Win32Helper.BringToForeground(currentWindows); } else { var groups = split.GroupBy(x => new { Dir = Path.GetDirectoryName(x), - Prog = Win32API.GetFileAssociationAsync(x).Result ?? Path.GetExtension(x) + Prog = Win32Helper.GetFileAssociationAsync(x).Result ?? Path.GetExtension(x) }); foreach (var group in groups) @@ -170,7 +170,7 @@ private static async Task HandleApplicationLaunch(string application, stri { if (application.StartsWith(@"\\SHELL\", StringComparison.Ordinal)) { - opened = await Win32API.StartSTATask(async () => + opened = await Win32Helper.StartSTATask(async () => { using var cMenu = await ContextMenu.GetContextMenuForFiles(new[] { application }, Shell32.CMF.CMF_DEFAULTONLY); diff --git a/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs b/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs index 083f338a4cf7..4aab6345bc2d 100644 --- a/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs +++ b/src/Files.App/Utils/Storage/Helpers/FileSecurityHelpers.cs @@ -55,7 +55,7 @@ public static bool SetOwner(string path, string sid) // Run PowerShell as Admin if (result.Failed) { - return Win32API.RunPowershellCommand( + return Win32Helper.RunPowershellCommand( $"-command \"try {{ $path = '{path}'; $ID = new-object System.Security.Principal.SecurityIdentifier('{sid}'); $acl = get-acl $path; $acl.SetOwner($ID); set-acl -path $path -aclObject $acl }} catch {{ exit 1; }}\"", true); } diff --git a/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs b/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs index 22303355c772..3f69c7348ca7 100644 --- a/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs +++ b/src/Files.App/Utils/Storage/Helpers/FileThumbnailHelper.cs @@ -15,7 +15,7 @@ public static class FileThumbnailHelper var size = iconOptions.HasFlag(IconOptions.UseCurrentScale) ? requestedSize * App.AppModel.AppWindowDPI : requestedSize; var returnIconOnly = iconOptions.HasFlag(IconOptions.ReturnIconOnly); - return await Win32API.StartSTATask(() => Win32API.GetIcon(path, (int)size, isFolder, returnIconOnly)); + return await Win32Helper.StartSTATask(() => Win32Helper.GetIcon(path, (int)size, isFolder, returnIconOnly)); } /// @@ -25,7 +25,7 @@ public static class FileThumbnailHelper /// /// public static async Task GetIconOverlayAsync(string path, bool isFolder) - => await Win32API.StartSTATask(() => Win32API.GetIconOverlay(path, isFolder)); + => await Win32Helper.StartSTATask(() => Win32Helper.GetIconOverlay(path, isFolder)); [Obsolete] public static async Task LoadIconFromPathAsync(string filePath, uint thumbnailSize, ThumbnailMode thumbnailMode, ThumbnailOptions thumbnailOptions, bool isFolder = false) diff --git a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs index b6f118751825..9745dc04e3da 100644 --- a/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs +++ b/src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs @@ -25,7 +25,7 @@ public class FileOperationsHelpers public static Task SetClipboard(string[] filesToCopy, DataPackageOperation operation) { - return Win32API.StartSTATask(() => + return Win32Helper.StartSTATask(() => { System.Windows.Forms.Clipboard.Clear(); var fileList = new System.Collections.Specialized.StringCollection(); @@ -41,7 +41,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera public static Task<(bool, ShellOperationResult)> CreateItemAsync(string filePath, string fileOp, long ownerHwnd, bool asAdmin, string template = "", byte[]? dataBytes = null) { - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); @@ -110,7 +110,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera public static Task<(bool, ShellOperationResult)> TestRecycleAsync(string[] fileToDeletePath) { - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); @@ -219,7 +219,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera fsProgress.Report(); progressHandler ??= new(); - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); @@ -337,7 +337,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera progressHandler ??= new(); - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); var shellOperationResult = new ShellOperationResult(); @@ -421,7 +421,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera fsProgress.Report(); progressHandler ??= new(); - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); var shellOperationResult = new ShellOperationResult(); @@ -549,7 +549,7 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera fsProgress.Report(); progressHandler ??= new(); - return Win32API.StartSTATask(async () => + return Win32Helper.StartSTATask(async () => { using var op = new ShellFileOperations2(); @@ -699,7 +699,7 @@ public static void TryCancelOperation(string operationId) } else if (FileExtensionHelpers.IsWebLinkFile(linkPath)) { - targetPath = await Win32API.StartSTATask(() => + targetPath = await Win32Helper.StartSTATask(() => { var ipf = new Url.IUniformResourceLocator(); (ipf as System.Runtime.InteropServices.ComTypes.IPersistFile).Load(linkPath, 0); @@ -746,7 +746,7 @@ public static Task CreateOrUpdateLinkAsync(string linkSavePath, string tar } else if (FileExtensionHelpers.IsWebLinkFile(linkSavePath)) { - return Win32API.StartSTATask(() => + return Win32Helper.StartSTATask(() => { var ipf = new Url.IUniformResourceLocator(); ipf.SetUrl(targetPath, Url.IURL_SETURL_FLAGS.IURL_SETURL_FL_GUESS_PROTOCOL); @@ -784,7 +784,7 @@ public static bool SetLinkIcon(string filePath, string iconFile, int iconIndex) public static Task OpenObjectPickerAsync(long hWnd) { - return Win32API.StartSTATask(() => + return Win32Helper.StartSTATask(() => { var picker = new DirectoryObjectPickerDialog() { @@ -800,7 +800,7 @@ public static bool SetLinkIcon(string filePath, string iconFile, int iconIndex) using (picker) { - if (picker.ShowDialog(Win32API.Win32Window.FromLong(hWnd)) == System.Windows.Forms.DialogResult.OK) + if (picker.ShowDialog(Win32Helper.Win32Window.FromLong(hWnd)) == System.Windows.Forms.DialogResult.OK) { try { @@ -933,7 +933,7 @@ public class OperationWithProgress public ProgressHandler() { - taskbar = Win32API.CreateTaskbarObject(); + taskbar = Win32Helper.CreateTaskbarObject(); operations = new ConcurrentDictionary(); operationsCompletedEvent = new ManualResetEvent(true); } diff --git a/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs index 4eb6f9ab4a7a..957583624c8a 100644 --- a/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs +++ b/src/Files.App/Utils/Storage/StorageItems/ShellStorageFolder.cs @@ -108,7 +108,7 @@ public static IAsyncOperation FromPathAsync(string path) protected static async Task<(ShellFileItem Folder, List Items)> GetFolderAndItems(string path, bool enumerate, int startIndex = 0, int maxItemsToRetrieve = int.MaxValue) { - return await Win32Shell.GetShellFolderAsync(path, enumerate ? "Enumerate" : "Query", startIndex, maxItemsToRetrieve); + return await Win32Helper.GetShellFolderAsync(path, enumerate ? "Enumerate" : "Query", startIndex, maxItemsToRetrieve); } public override IAsyncOperation ToStorageFolderAsync() => throw new NotSupportedException(); diff --git a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs index d6262f4a79a7..39e49d55de1b 100644 --- a/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs +++ b/src/Files.App/ViewModels/Properties/BasePropertiesPage.cs @@ -45,7 +45,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) { try { - await Win32API.OpenFormatDriveDialog(props.Drive.Path); + await Win32Helper.OpenFormatDriveDialog(props.Drive.Path); } catch (Exception) { diff --git a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs index c46d3c599764..87a12c11f291 100644 --- a/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs +++ b/src/Files.App/ViewModels/Properties/CustomizationViewModel.cs @@ -112,14 +112,14 @@ public async Task UpdateIcon() if (SelectedDllIcon is null) { result = IsShortcut - ? Win32API.SetCustomFileIcon(_selectedItemPath, null) - : Win32API.SetCustomDirectoryIcon(_selectedItemPath, null); + ? Win32Helper.SetCustomFileIcon(_selectedItemPath, null) + : Win32Helper.SetCustomDirectoryIcon(_selectedItemPath, null); } else { result = IsShortcut - ? Win32API.SetCustomFileIcon(_selectedItemPath, IconResourceItemPath, SelectedDllIcon.Index) - : Win32API.SetCustomDirectoryIcon(_selectedItemPath, IconResourceItemPath, SelectedDllIcon.Index); + ? Win32Helper.SetCustomFileIcon(_selectedItemPath, IconResourceItemPath, SelectedDllIcon.Index) + : Win32Helper.SetCustomDirectoryIcon(_selectedItemPath, IconResourceItemPath, SelectedDllIcon.Index); } if (!result) @@ -138,7 +138,7 @@ private void LoadIconsForPath(string path) IconResourceItemPath = path; DllIcons.Clear(); - var icons = Win32API.ExtractIconsFromDLL(path); + var icons = Win32Helper.ExtractIconsFromDLL(path); if (icons?.Count is null or 0) return; diff --git a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs index 65b9806b8423..2a4203a45509 100644 --- a/src/Files.App/ViewModels/Properties/Items/FileProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FileProperties.cs @@ -77,7 +77,7 @@ public override void GetBaseProperties() if (Item.IsLinkItem) { var tmpItem = (ShortcutItem)Item; - await Win32Helpers.InvokeWin32ComponentAsync(ViewModel.ShortcutItemPath, AppInstance, ViewModel.ShortcutItemArguments, ViewModel.RunAsAdmin, ViewModel.ShortcutItemWorkingDir); + await Win32Helper.InvokeWin32ComponentAsync(ViewModel.ShortcutItemPath, AppInstance, ViewModel.ShortcutItemArguments, ViewModel.RunAsAdmin, ViewModel.ShortcutItemWorkingDir); } else { diff --git a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs index 0a15d5477081..b1791215461d 100644 --- a/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs +++ b/src/Files.App/ViewModels/Properties/Items/FolderProperties.cs @@ -123,7 +123,7 @@ CloudDriveSyncStatus.FolderOnline and not } else if (Item.ItemPath.Equals(Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)) { - var recycleBinQuery = Win32Shell.QueryRecycleBin(); + var recycleBinQuery = Win32Helper.QueryRecycleBin(); if (recycleBinQuery.BinSize is long binSize) { ViewModel.ItemSizeBytes = binSize; diff --git a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs index 7c1c3191796b..97086116d3ca 100644 --- a/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Settings/AdvancedViewModel.cs @@ -77,7 +77,7 @@ private async Task SetAsDefaultExplorerAsync() var dataPath = Environment.ExpandEnvironmentVariables("%LocalAppData%\\Files"); if (IsSetAsDefaultFileManager) { - if (!await Win32API.RunPowershellCommandAsync($"-command \"New-Item -Force -Path '{dataPath}' -ItemType Directory; Copy-Item -Filter *.* -Path '{destFolder}\\*' -Recurse -Force -Destination '{dataPath}'\"", false)) + if (!await Win32Helper.RunPowershellCommandAsync($"-command \"New-Item -Force -Path '{dataPath}' -ItemType Directory; Copy-Item -Filter *.* -Path '{destFolder}\\*' -Recurse -Force -Destination '{dataPath}'\"", false)) { // Error copying files await DetectResult(); @@ -86,7 +86,7 @@ private async Task SetAsDefaultExplorerAsync() } else { - await Win32API.RunPowershellCommandAsync($"-command \"Remove-Item -Path '{dataPath}' -Recurse -Force\"", false); + await Win32Helper.RunPowershellCommandAsync($"-command \"Remove-Item -Path '{dataPath}' -Recurse -Force\"", false); } try diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index ffd0f2b9af3b..fe29f8fc0487 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -759,7 +759,7 @@ await DialogDisplayHelper.ShowDialogAsync("CommandNotExecutable".GetLocalizedRes if (resFile) { var pathToInvoke = resFile.Result.Path; - await Win32Helpers.InvokeWin32ComponentAsync(pathToInvoke, shellPage); + await Win32Helper.InvokeWin32ComponentAsync(pathToInvoke, shellPage); } else // Not a file or not accessible { diff --git a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs index 198afe0ba36f..1a3702389164 100644 --- a/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/SidebarViewModel.cs @@ -932,7 +932,7 @@ private async Task EjectDeviceAsync() private void FormatDrive() { - Win32API.OpenFormatDriveDialog(rightClickedItem.Path); + Win32Helper.OpenFormatDriveDialog(rightClickedItem.Path); } private List GetLocationItemMenuItems(INavigationControlItem item, CommandBarFlyout menu) diff --git a/src/Files.App/Views/HomePage.xaml.cs b/src/Files.App/Views/HomePage.xaml.cs index b7964362d476..437d6c7d9ee6 100644 --- a/src/Files.App/Views/HomePage.xaml.cs +++ b/src/Files.App/Views/HomePage.xaml.cs @@ -196,7 +196,7 @@ private async void RecentFilesWidget_RecentFileInvoked(object sender, PathNaviga if (e.IsFile) { var directoryName = Path.GetDirectoryName(e.ItemPath); - await Win32Helpers.InvokeWin32ComponentAsync(e.ItemPath, AppInstance, workingDirectory: directoryName ?? string.Empty); + await Win32Helper.InvokeWin32ComponentAsync(e.ItemPath, AppInstance, workingDirectory: directoryName ?? string.Empty); } else { diff --git a/src/Files.App/Views/Properties/GeneralPage.xaml.cs b/src/Files.App/Views/Properties/GeneralPage.xaml.cs index 1453108ac925..f9b1ad91c7ec 100644 --- a/src/Files.App/Views/Properties/GeneralPage.xaml.cs +++ b/src/Files.App/Views/Properties/GeneralPage.xaml.cs @@ -88,9 +88,9 @@ bool SaveDrive(DriveItem drive) newName = letterRegex.Replace(newName, string.Empty); // Remove "(C:)" from the new label if (drive.Type == Data.Items.DriveType.Network) - Win32API.SetNetworkDriveLabel(drive.DeviceID, newName); + Win32Helper.SetNetworkDriveLabel(drive.DeviceID, newName); else - Win32API.SetVolumeLabel(drive.Path, newName); + Win32Helper.SetVolumeLabel(drive.Path, newName); _ = MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { From 8b865619a0fb80a8ad03075fe5fe20f144128e3f Mon Sep 17 00:00:00 2001 From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com> Date: Wed, 13 Mar 2024 00:17:17 +0900 Subject: [PATCH 3/3] Fix --- .../ViewModels/Properties/SecurityAdvancedViewModel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs index 463d28396c5c..d8cb7507ca56 100644 --- a/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs +++ b/src/Files.App/ViewModels/Properties/SecurityAdvancedViewModel.cs @@ -156,7 +156,7 @@ private void LoadShieldIconResource() { string imageres = System.IO.Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll"); - var imageResList = Utils.Shell.Win32API.ExtractSelectedIconsFromDLL( + var imageResList = Win32Helper.ExtractSelectedIconsFromDLL( imageres, new List() { Constants.ImageRes.ShieldIcon }, 16);