mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Cleanup dead code
This commit is contained in:
@@ -2,11 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Properties;
|
||||
|
||||
@@ -2,15 +2,8 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
@@ -18,10 +11,6 @@ namespace Microsoft.CmdPal.Ext.WindowWalker.Commands;
|
||||
|
||||
internal sealed partial class ExplorerInfoResultCommand : InvokableCommand
|
||||
{
|
||||
public ExplorerInfoResultCommand()
|
||||
{
|
||||
}
|
||||
|
||||
public static bool OpenInShell(string path, string? arguments = null, string? workingDir = null, ShellRunAsType runAs = ShellRunAsType.None, bool runWithHiddenWindow = false)
|
||||
{
|
||||
using var process = new Process();
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Commands;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Pages;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
using Windows.System;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Commands;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Pages;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Properties;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
|
||||
@@ -97,14 +97,6 @@ public static partial class NativeMethods
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetShellWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool EnumThreadWindows(uint threadId, ShellCommand.EnumThreadDelegate lpfn, IntPtr lParam);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetFirmwareType(ref FirmwareType FirmwareType);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool OpenProcessToken(SafeProcessHandle processHandle, TokenAccess desiredAccess, out SafeAccessTokenHandle tokenHandle);
|
||||
@@ -265,113 +257,8 @@ public enum HRESULT : uint
|
||||
E_CANCELLED = 0x800704C7,
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// <see href="https://learn.microsoft.com/windows/win32/api/winnt/ne-winnt-firmware_type">see learn.microsoft.com</see>
|
||||
/// </remarks>
|
||||
public enum FirmwareType
|
||||
{
|
||||
Unknown = 0,
|
||||
Bios = 1,
|
||||
Uefi = 2,
|
||||
Max = 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see href="https://learn.microsoft.com/windows/win32/stg/stgm-constants">see all STGM values</see>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum STGM : long
|
||||
{
|
||||
READ = 0x00000000L,
|
||||
WRITE = 0x00000001L,
|
||||
READWRITE = 0x00000002L,
|
||||
CREATE = 0x00001000L,
|
||||
}
|
||||
|
||||
public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
|
||||
|
||||
/// <summary>
|
||||
/// Some flags for interop calls to SetWindowPosition
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SetWindowPosFlags : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// If the calling thread and the thread that owns the window are attached to different input queues, the system posts the request to the thread that owns the window. This prevents the calling thread from blocking its execution while other threads process the request.
|
||||
/// </summary>
|
||||
SWP_ASYNCWINDOWPOS = 0x4000,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents generation of the WM_SYNCPAINT message.
|
||||
/// </summary>
|
||||
SWP_DEFERERASE = 0x2000,
|
||||
|
||||
/// <summary>
|
||||
/// Draws a frame (defined in the window's class description) around the window.
|
||||
/// </summary>
|
||||
SWP_DRAWFRAME = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed.
|
||||
/// </summary>
|
||||
SWP_FRAMECHANGED = 0x0020,
|
||||
|
||||
/// <summary>
|
||||
/// Hides the window.
|
||||
/// </summary>
|
||||
SWP_HIDEWINDOW = 0x0080,
|
||||
|
||||
/// <summary>
|
||||
/// Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter).
|
||||
/// </summary>
|
||||
SWP_NOACTIVATE = 0x0010,
|
||||
|
||||
/// <summary>
|
||||
/// Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client area are saved and copied back into the client area after the window is sized or repositioned.
|
||||
/// </summary>
|
||||
SWP_NOCOPYBITS = 0x0100,
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current position (ignores X and Y parameters).
|
||||
/// </summary>
|
||||
SWP_NOMOVE = 0x0002,
|
||||
|
||||
/// <summary>
|
||||
/// Does not change the owner window's position in the Z order.
|
||||
/// </summary>
|
||||
SWP_NOOWNERZORDER = 0x0200,
|
||||
|
||||
/// <summary>
|
||||
/// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing.
|
||||
/// </summary>
|
||||
SWP_NOREDRAW = 0x0008,
|
||||
|
||||
/// <summary>
|
||||
/// Same as the SWP_NOOWNERZORDER flag.
|
||||
/// </summary>
|
||||
SWP_NOREPOSITION = 0x0200,
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
|
||||
/// </summary>
|
||||
SWP_NOSENDCHANGING = 0x0400,
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current size (ignores the cx and cy parameters).
|
||||
/// </summary>
|
||||
SWP_NOSIZE = 0x0001,
|
||||
|
||||
/// <summary>
|
||||
/// Retains the current Z order (ignores the hWndInsertAfter parameter).
|
||||
/// </summary>
|
||||
SWP_NOZORDER = 0x0004,
|
||||
|
||||
/// <summary>
|
||||
/// Displays the window.
|
||||
/// </summary>
|
||||
SWP_SHOWWINDOW = 0x0040,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for DwmpActivateLivePreview
|
||||
/// </summary>
|
||||
@@ -655,16 +542,6 @@ public enum ProcessAccessFlags
|
||||
AllAccess = StandardRightsRequired | Synchronize | 0xFFFF,
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct GUIDDATA
|
||||
{
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public byte[] Data4;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains information about the placement of a window on the screen.
|
||||
/// </summary>
|
||||
@@ -920,7 +797,7 @@ public struct POINT : IEquatable<POINT>
|
||||
{
|
||||
if (obj is POINT pt)
|
||||
{
|
||||
return this.X == pt.X && this.Y == pt.X;
|
||||
return X == pt.X && Y == pt.X;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1145,22 +1022,6 @@ public enum ExtendedWindowStyles : uint
|
||||
WS_EX_NOACTIVATE = 0x8000000,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The following are ShellItem DisplayName types.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SIGDN : uint
|
||||
{
|
||||
NORMALDISPLAY = 0,
|
||||
PARENTRELATIVEPARSING = 0x80018001,
|
||||
PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
|
||||
DESKTOPABSOLUTEPARSING = 0x80028000,
|
||||
PARENTRELATIVEEDITING = 0x80031001,
|
||||
DESKTOPABSOLUTEEDITING = 0x8004c000,
|
||||
FILESYSPATH = 0x80058000,
|
||||
URL = 0x80068000,
|
||||
}
|
||||
|
||||
internal enum TOKEN_INFORMATION_CLASS
|
||||
{
|
||||
TokenIsAppContainer = 29,
|
||||
|
||||
@@ -12,9 +12,4 @@ public static class OSVersionHelper
|
||||
{
|
||||
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 22000;
|
||||
}
|
||||
|
||||
public static bool IsGreaterThanWindows11_21H2()
|
||||
{
|
||||
return Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build > 22000;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
@@ -123,7 +123,7 @@ public class SettingsManager : JsonSettingsManager, ISettingsInterface
|
||||
// Load settings from file upon initialization
|
||||
LoadSettings();
|
||||
|
||||
Settings.SettingsChanged += (s, a) => this.SaveSettings();
|
||||
Settings.SettingsChanged += (_, _) => SaveSettings();
|
||||
}
|
||||
|
||||
internal static SettingsManager Instance
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
|
||||
public static class ShellCommand
|
||||
{
|
||||
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
|
||||
|
||||
private static bool containsSecurityWindow;
|
||||
|
||||
public static Process? RunAsDifferentUser(ProcessStartInfo processStartInfo)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(processStartInfo);
|
||||
|
||||
processStartInfo.Verb = "RunAsUser";
|
||||
var process = Process.Start(processStartInfo);
|
||||
|
||||
containsSecurityWindow = false;
|
||||
|
||||
// wait for windows to bring up the "Windows Security" dialog
|
||||
while (!containsSecurityWindow)
|
||||
{
|
||||
CheckSecurityWindow();
|
||||
Thread.Sleep(25);
|
||||
}
|
||||
|
||||
// while this process contains a "Windows Security" dialog, stay open
|
||||
while (containsSecurityWindow)
|
||||
{
|
||||
containsSecurityWindow = false;
|
||||
CheckSecurityWindow();
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
|
||||
return process;
|
||||
}
|
||||
|
||||
private static void CheckSecurityWindow()
|
||||
{
|
||||
ProcessThreadCollection ptc = Process.GetCurrentProcess().Threads;
|
||||
for (var i = 0; i < ptc.Count; i++)
|
||||
{
|
||||
NativeMethods.EnumThreadWindows((uint)ptc[i].Id, CheckSecurityThread, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckSecurityThread(IntPtr hwnd, IntPtr lParam)
|
||||
{
|
||||
if (GetWindowTitle(hwnd) == "Windows Security")
|
||||
{
|
||||
containsSecurityWindow = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string GetWindowTitle(IntPtr hwnd)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(NativeMethods.GetWindowTextLength(hwnd) + 1);
|
||||
_ = NativeMethods.GetWindowText(hwnd, sb, sb.Capacity);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static ProcessStartInfo SetProcessStartInfo(this string fileName, string workingDirectory = "", string arguments = "", string verb = "")
|
||||
{
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
WorkingDirectory = workingDirectory,
|
||||
Arguments = arguments,
|
||||
Verb = verb,
|
||||
};
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class VirtualDesktopHelper
|
||||
/// </summary>
|
||||
private Guid _currentDesktop;
|
||||
|
||||
private static readonly CompositeFormat VirtualDesktopHelperDesktop = System.Text.CompositeFormat.Parse(Properties.Resources.VirtualDesktopHelper_Desktop);
|
||||
private static readonly CompositeFormat VirtualDesktopHelperDesktop = CompositeFormat.Parse(Resources.VirtualDesktopHelper_Desktop);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="VirtualDesktopHelper"/> class.
|
||||
|
||||
@@ -9,17 +9,6 @@ namespace Microsoft.CmdPal.Ext.WindowWalker.Helpers;
|
||||
|
||||
public static class Win32Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Detects the type of system firmware which is equal to the boot type by calling the method <see cref="NativeMethods.GetFirmwareType"/>.
|
||||
/// </summary>
|
||||
/// <returns>Firmware type like Uefi or Bios.</returns>
|
||||
public static FirmwareType GetSystemFirmwareType()
|
||||
{
|
||||
FirmwareType firmwareType = default;
|
||||
_ = NativeMethods.GetFirmwareType(ref firmwareType);
|
||||
return firmwareType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the last Win32 Error code thrown by a native method if enabled for this method.
|
||||
/// </summary>
|
||||
@@ -44,14 +33,4 @@ public static class Win32Helpers
|
||||
|
||||
return NativeMethods.CloseHandle(handle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description for an HRESULT error code.
|
||||
/// </summary>
|
||||
/// <param name="hr">The HRESULT number</param>
|
||||
/// <returns>A string containing the description.</returns>
|
||||
public static string MessageFromHResult(int hr)
|
||||
{
|
||||
return Marshal.GetExceptionForHR(hr)?.Message ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,11 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Commands;
|
||||
using Microsoft.CmdPal.Ext.WindowWalker.Components;
|
||||
using Microsoft.CommandPalette.Extensions.Toolkit;
|
||||
|
||||
namespace Microsoft.CmdPal.Ext.WindowWalker;
|
||||
namespace Microsoft.CmdPal.Ext.WindowWalker.Pages;
|
||||
|
||||
internal sealed partial class WindowWalkerListItem : ListItem
|
||||
{
|
||||
Reference in New Issue
Block a user