From 2f93d41abbcb4e6fdabe8deae6e3a48601eba84f Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Sun, 26 May 2024 12:29:48 +0200 Subject: [PATCH] Remove obsolete native imports --- ILSpy/NativeMethods.cs | 79 ------------------------------------------ 1 file changed, 79 deletions(-) diff --git a/ILSpy/NativeMethods.cs b/ILSpy/NativeMethods.cs index d24aeba6d..8ba9b02fa 100644 --- a/ILSpy/NativeMethods.cs +++ b/ILSpy/NativeMethods.cs @@ -17,73 +17,12 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel; -using System.Diagnostics; using System.Runtime.InteropServices; -using System.Text; namespace ICSharpCode.ILSpy { static class NativeMethods { - public const uint WM_COPYDATA = 0x4a; - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - internal static extern unsafe int GetWindowThreadProcessId(IntPtr hWnd, int* lpdwProcessId); - - [DllImport("user32.dll", CharSet = CharSet.Unicode)] - static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder title, int size); - - public static string GetWindowText(IntPtr hWnd, int maxLength) - { - StringBuilder b = new StringBuilder(maxLength + 1); - if (GetWindowText(hWnd, b, b.Capacity) != 0) - return b.ToString(); - else - return string.Empty; - } - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr SendMessageTimeout( - IntPtr hWnd, uint msg, IntPtr wParam, ref CopyDataStruct lParam, - uint flags, uint timeout, out IntPtr result); - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetForegroundWindow(IntPtr hWnd); - - public unsafe static string GetProcessNameFromWindow(IntPtr hWnd) - { - int processId; - GetWindowThreadProcessId(hWnd, &processId); - try - { - using (var p = Process.GetProcessById(processId)) - { - return p.ProcessName; - } - } - catch (ArgumentException ex) - { - Debug.WriteLine(ex.Message); - return null; - } - catch (InvalidOperationException ex) - { - Debug.WriteLine(ex.Message); - return null; - } - catch (Win32Exception ex) - { - Debug.WriteLine(ex.Message); - return null; - } - } - [DllImport("dwmapi.dll", PreserveSig = true)] public static extern int DwmSetWindowAttribute(IntPtr hwnd, DwmWindowAttribute attr, ref int attrValue, int attrSize); @@ -95,24 +34,6 @@ namespace ICSharpCode.ILSpy } } - [return: MarshalAs(UnmanagedType.Bool)] - delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); - - [StructLayout(LayoutKind.Sequential)] - struct CopyDataStruct - { - public IntPtr Padding; - public int Size; - public IntPtr Buffer; - - public CopyDataStruct(IntPtr padding, int size, IntPtr buffer) - { - this.Padding = padding; - this.Size = size; - this.Buffer = buffer; - } - } - public enum DwmWindowAttribute : uint { NCRenderingEnabled = 1,