using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; namespace SmartCoalApplication.SystemLayer.FileDlgExtenders.Win32Types { internal static class NativeMethods { #region Delegates internal delegate bool EnumWindowsCallBack(IntPtr hWnd, int lParam); #endregion #region USER32 [DllImport("user32.dll")] public static extern bool IsWindow(IntPtr hwnd); [DllImport("user32.dll")] internal static extern IntPtr CreateWindowEx( uint dwExStyle, string lpClassName, string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr GetParent(IntPtr hWnd); [DllImport("user32.dll")] internal static extern bool EnableWindow(IntPtr hWnd, bool bEnable); [DllImport("user32.dll")] internal static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem); [DllImport("user32.dll")] internal static extern bool SetDlgItemText(IntPtr hDlg, int nIDDlgItem, string lpString); [DllImport("User32.Dll")] public static extern int GetDlgCtrlID(IntPtr hWndCtl); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetWindowInfo(HandleRef hwnd, out WINDOWINFO pwi); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetWindowText(HandleRef hWnd, string lpString); [DllImport("User32.Dll")] public static extern void GetClassName(HandleRef hWnd, StringBuilder param, int length); [DllImport("user32.Dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool EnumChildWindows(HandleRef hWndParent, EnumWindowsCallBack lpEnumFunc, int lParam); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle); [DllImport("user32.dll")] internal static extern IntPtr SetParent(HandleRef hWndChild, HandleRef hWndNewParent); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] internal static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] internal static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, StringBuilder lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int Width, int Height, SetWindowPosFlags flags); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetWindowRect(HandleRef hwnd, ref RECT rect); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetClientRect(HandleRef hwnd, ref RECT rect); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DestroyWindow(IntPtr hWnd); [DllImport("advapi32.dll", EntryPoint = "RegCreateKeyW")] public static extern int RegCreateKeyW([In] UIntPtr hKey, [In] [MarshalAs(UnmanagedType.LPWStr)] string lpSubKey, out IntPtr phkResult); [DllImport("advapi32.dll", EntryPoint = "RegOverridePredefKey")] public static extern int RegOverridePredefKey([In] UIntPtr hKey, [In] IntPtr hNewHKey); [DllImport("advapi32.dll", EntryPoint = "RegCloseKey")] public static extern int RegCloseKey([In] IntPtr hKey); /* [DllImport("user32.dll")] public static extern IntPtr SetActiveWindow(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr SetForegeoundWindow(IntPtr hWnd); */ #endregion } }