diff --git a/SuperLauncher/ComInterop.cs b/SuperLauncher/ComInterop.cs index 7bfe7c6..8ea80f7 100644 --- a/SuperLauncher/ComInterop.cs +++ b/SuperLauncher/ComInterop.cs @@ -10,9 +10,9 @@ public class ExplorerBrowser { } [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("dfd3b6b5-c10c-4be9-85f6-a66969f402f6")] public interface IExplorerBrowser { - public uint Initialize([In] IntPtr hwndParent, [In] ref Win32Interop.RECT prc, [In, Optional] ref FOLDERSETTINGS pfs); + public uint Initialize([In] nint hwndParent, [In] ref Win32Interop.RECT prc, [In, Optional] ref FOLDERSETTINGS pfs); public uint Destroy(); - public uint SetRect([In, Out] ref IntPtr phdwp, [In] Win32Interop.RECT rcBrowser); + public uint SetRect([In, Out] ref nint phdwp, [In] Win32Interop.RECT rcBrowser); public uint SetPropertyBag([In] string pszPropertyBag); public uint SetEmptyText([In] string pszEmptyText); public uint SetFolderSettings([In] ref FOLDERSETTINGS pfs); @@ -20,64 +20,64 @@ public interface IExplorerBrowser public uint Unadvise([In] uint dwCookie); public uint SetOptions([In] EXPLORER_BROWSER_OPTIONS dwFlags); public uint GetOptions([Out] out EXPLORER_BROWSER_OPTIONS pdwFlags); - public uint BrowseToIDList([In] IntPtr pidl, [In] BROWSETOFLAGS uFlags); - public uint BrowseToObjects([In] IntPtr punk, [In] BROWSETOFLAGS uflags); - public uint FillFromObject([In] IntPtr punk, [In] EXPLORER_BROWSER_FILL_FLAGS dwFlags); + public uint BrowseToIDList([In] nint pidl, [In] BROWSETOFLAGS uFlags); + public uint BrowseToObjects([In] nint punk, [In] BROWSETOFLAGS uflags); + public uint FillFromObject([In] nint punk, [In] EXPLORER_BROWSER_FILL_FLAGS dwFlags); public uint RemoveAll(); - public uint GetCurrentView([In] Guid riid, [Out] out IntPtr ppv); + public uint GetCurrentView([In] Guid riid, [Out] out nint ppv); } [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00000114-0000-0000-c000-000000000046")] public interface IOleWindow { - public uint GetWindow([Out] out IntPtr phwnd); + public uint GetWindow([Out] out nint phwnd); public uint ContextSensitiveHelp([In] bool fEnterMode); } [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E3-0000-0000-C000-000000000046")] public interface IShellView { - public uint GetWindow([Out] out IntPtr phwnd); + public uint GetWindow([Out] out nint phwnd); public uint ContextSensitiveHelp([In] bool fEnterMode); - public uint TranslateAccelerator([In] IntPtr pmsg); + public uint TranslateAccelerator([In] nint pmsg); public uint EnableModeless([In] bool fEnable); public uint UIActivate([In] uint uState); public uint Refresh(); - public uint CreateViewWindow([In] ref IShellView psvPrevious, [In] FOLDERSETTINGS pfs, [In] IntPtr psb, [In] ref Win32Interop.RECT prcView, [Out] out IntPtr phWnd); + public uint CreateViewWindow([In] ref IShellView psvPrevious, [In] FOLDERSETTINGS pfs, [In] nint psb, [In] ref Win32Interop.RECT prcView, [Out] out nint phWnd); public uint DestroyViewWindow(); public uint GetCurrentInfo([Out] out FOLDERSETTINGS pfs); public uint AddPropertySheetPages([In] uint dwReserved, [In] object pfn, [In] uint lparam); public uint SaveViewState(); - public uint SelectItem([In] IntPtr pidlItem, [In] uint uFlags); - public uint GetItemObject([In] uint uItem, [In] Guid riid, [Out] out IntPtr ppv); + public uint SelectItem([In] nint pidlItem, [In] uint uFlags); + public uint GetItemObject([In] uint uItem, [In] Guid riid, [Out] out nint ppv); } [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("cde725b0-ccc9-4519-917e-325d72fab4ce")] public interface IFolderView { - public uint GetCurrentViewMode([Out] out IntPtr pViewMode); + public uint GetCurrentViewMode([Out] out nint pViewMode); public uint SetCurrentViewMode([In] FOLDERVIEWMODE ViewMode); - public uint GetFolder([In] Guid riid, [Out] out IntPtr ppv); - public uint Item([In] int iItemIndex, [Out] out IntPtr ppidl); - public uint ItemCount([In] SVGIO uFlags, [Out] out IntPtr pcItems); - public uint Items([In] SVGIO uFlags, [In] Guid riid, [Out] out IntPtr ppv); - public uint GetSelectionMarkedItem([Out] out IntPtr piItem); - public uint GetFocusedItem([Out] out IntPtr piItem); - public uint GetItemPosition([In] IntPtr pidl, [Out] IntPtr ppt); - public uint GetSpacing([Out][In] IntPtr ppt); - public uint GetDefaultSpacing([Out] out IntPtr ppt); + public uint GetFolder([In] Guid riid, [Out] out nint ppv); + public uint Item([In] int iItemIndex, [Out] out nint ppidl); + public uint ItemCount([In] SVGIO uFlags, [Out] out nint pcItems); + public uint Items([In] SVGIO uFlags, [In] Guid riid, [Out] out nint ppv); + public uint GetSelectionMarkedItem([Out] out nint piItem); + public uint GetFocusedItem([Out] out int piItem); + public uint GetItemPosition([In] nint pidl, [Out] nint ppt); + public uint GetSpacing([Out][In] nint ppt); + public uint GetDefaultSpacing([Out] out nint ppt); public uint GetAutoArrange(); public uint SelectItem([In] int iItem, [In] SVSIF dwFlags); - public uint SelectAndPositionItems([In] uint cidl, [In] IntPtr apidl, [In] IntPtr apt, [In] SVSIF dwFlags); + public uint SelectAndPositionItems([In] uint cidl, [In] nint apidl, [In] nint apt, [In] SVSIF dwFlags); } [ComImport, Guid("361bbdc7-e6ee-4e13-be58-58e2240c810f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IExplorerBrowserEvents { [PreserveSig] - uint OnNavigationPending([In] IntPtr pidlFolder); + uint OnNavigationPending([In] nint pidlFolder); [PreserveSig] - uint OnViewCreated([In] IntPtr psv); + uint OnViewCreated([In] nint psv); [PreserveSig] - uint OnNavigationComplete([In] IntPtr pidlFolder); + uint OnNavigationComplete([In] nint pidlFolder); [PreserveSig] - uint OnNavigationFailed([In] IntPtr pidlFolder); + uint OnNavigationFailed([In] nint pidlFolder); } [StructLayout(LayoutKind.Sequential)] public struct FOLDERSETTINGS diff --git a/SuperLauncher/CredentialManager.cs b/SuperLauncher/CredentialManager.cs index c4e1220..b82991a 100644 --- a/SuperLauncher/CredentialManager.cs +++ b/SuperLauncher/CredentialManager.cs @@ -9,12 +9,12 @@ public static class CredentialManager [DllImport("advapi32.dll")] public static extern bool CredWriteA(CREDENTIAL Credential, CredWriteFlags Flags); [DllImport("advapi32.dll")] - public static extern bool CredReadA(string TargetName, CredType Type, CredReadFlags Flags, out IntPtr Credential); + public static extern bool CredReadA(string TargetName, CredType Type, CredReadFlags Flags, out nint Credential); [DllImport("advapi32.dll")] public static extern bool CredDeleteA(string TargetName, CredType Type, CredDeleteFlags Flags); public static bool CredReadA(string TargetName, CredType Type, CredReadFlags Flags, out CREDENTIAL Credential) { - bool success = CredReadA(TargetName, Type, Flags, out IntPtr credPtr); + bool success = CredReadA(TargetName, Type, Flags, out nint credPtr); Credential = new(); try { Marshal.PtrToStructure(credPtr, Credential); } catch { } return success; @@ -28,7 +28,7 @@ public class CREDENTIAL public string Comment; public FILETIME LastWritten; public uint CredentialBlobSize; - public IntPtr CredentialBlob; + public nint CredentialBlob; public CredPersist Persist; public uint AttributeCount; public uint Attributes; diff --git a/SuperLauncher/Launcher.cs b/SuperLauncher/Launcher.cs index 8f509cb..b6d738e 100644 --- a/SuperLauncher/Launcher.cs +++ b/SuperLauncher/Launcher.cs @@ -21,9 +21,9 @@ public partial class Launcher : Form private readonly int HandleWidth = 5; private readonly int BottomRightMargin = 5; [DllImport("user32.dll", SetLastError = true)] - static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + static extern bool SetWindowPos(nint hWnd, nint hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); [DllImport("dwmapi.dll")] - private static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); + private static extern int DwmExtendFrameIntoClientArea(nint hwnd, ref MARGINS margins); [StructLayout(LayoutKind.Sequential)] private struct MARGINS { @@ -86,9 +86,9 @@ protected override void WndProc(ref Message m) } if (m.Msg == 0x1) //WM_CREATE { - SetWindowPos(Handle, IntPtr.Zero, Left, Top, Width, Height, 0x20); //SWP_FRAMECHANGED + SetWindowPos(Handle, nint.Zero, Left, Top, Width, Height, 0x20); //SWP_FRAMECHANGED } - if (m.Msg == 0x83 && m.WParam == (IntPtr)1) //WM_NCCALCSIZE + if (m.Msg == 0x83 && m.WParam == (nint)1) //WM_NCCALCSIZE { return; } diff --git a/SuperLauncher/ModernLauncher.xaml.cs b/SuperLauncher/ModernLauncher.xaml.cs index 75be2f0..c127221 100644 --- a/SuperLauncher/ModernLauncher.xaml.cs +++ b/SuperLauncher/ModernLauncher.xaml.cs @@ -61,7 +61,7 @@ public ModernLauncher() Width = Settings.Default.Width; Height = Settings.Default.Height; } - private IntPtr HwndSourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + private nint HwndSourceHook(nint hwnd, int msg, nint wParam, nint lParam, ref bool handled) { if (msg == 0x0312 && wParam.ToInt32() == 0) //WM_HOTKEY //ALT + S { @@ -79,7 +79,7 @@ private IntPtr HwndSourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam { OpenWindow(); } - return IntPtr.Zero; + return nint.Zero; } private void InitializeNotifyIcon() { @@ -114,7 +114,7 @@ private void UpdateAnimations(bool Center = false) { Win32Interop.MONITORINFO mi = new(); mi.cbSize = (uint)Marshal.SizeOf(mi); - IntPtr hMonitor = Win32Interop.MonitorFromWindow(WIH.Handle, Win32Interop.MonitorFromWindowFlags.MONITOR_DEFAULTTONEAREST); + nint hMonitor = Win32Interop.MonitorFromWindow(WIH.Handle, Win32Interop.MonitorFromWindowFlags.MONITOR_DEFAULTTONEAREST); Win32Interop.GetMonitorInfo(hMonitor, out mi); OpenTopAnimation.From = CloseTopAnimation.From = Top; CloseTopAnimation.To = DPI.ScalePixelsDown(mi.rcMonitor.bottom); @@ -215,7 +215,7 @@ private void CloseTopAnimation_Completed(object sender, EventArgs e) } private void OpenTopAnimation_Completed(object sender, EventArgs e) { - Win32Interop.InvalidateRect(WIH.Handle, IntPtr.Zero, false); + Win32Interop.InvalidateRect(WIH.Handle, nint.Zero, false); } private void ModernApplication_Exit(object sender, ExitEventArgs e) { diff --git a/SuperLauncher/ModernLauncherIcon.xaml.cs b/SuperLauncher/ModernLauncherIcon.xaml.cs index b87461a..f977907 100644 --- a/SuperLauncher/ModernLauncherIcon.xaml.cs +++ b/SuperLauncher/ModernLauncherIcon.xaml.cs @@ -1,7 +1,5 @@ using System; -using System.Diagnostics; using System.Drawing; -using System.Threading.Tasks; using System.Timers; using System.Windows; using System.Windows.Controls; @@ -164,19 +162,7 @@ private void BadgeTimer_Elapsed(object sender, ElapsedEventArgs e) public void StartProgram() { ((ModernLauncher)Window.GetWindow(this)).CloseWindow(); - Task.Run(() => - { - try - { - Process.Start(new ProcessStartInfo() - { - FileName = FilePath, - UseShellExecute = true, - WorkingDirectory = Environment.GetEnvironmentVariable("USERPROFILE") - }); - } - catch { } - }); + Shared.StartProcess(FilePath); } private void UserControl_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { diff --git a/SuperLauncher/ModernLauncherShared.cs b/SuperLauncher/ModernLauncherShared.cs index 9e1f6ba..829f674 100644 --- a/SuperLauncher/ModernLauncherShared.cs +++ b/SuperLauncher/ModernLauncherShared.cs @@ -1,6 +1,8 @@ using Microsoft.Win32; using System; +using System.Diagnostics; using System.Runtime.InteropServices; +using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; using System.Windows.Media; @@ -62,16 +64,16 @@ public static void SetWindowColor(Window Window) public static void EnableAcrylic(Window Window) { Window.Background = Brushes.Transparent; - IntPtr handle = new WindowInteropHelper(Window).Handle; - IntPtr dwmDmVal = Marshal.AllocHGlobal(4); + nint handle = new WindowInteropHelper(Window).Handle; + nint dwmDmVal = Marshal.AllocHGlobal(4); Marshal.WriteInt32(dwmDmVal, 1); Win32Interop.DwmSetWindowAttribute(handle, Win32Interop.DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, dwmDmVal, 4); Marshal.FreeHGlobal(dwmDmVal); - IntPtr dwmBdVal = Marshal.AllocHGlobal(4); + nint dwmBdVal = Marshal.AllocHGlobal(4); Marshal.WriteInt32(dwmBdVal, 3); Win32Interop.DwmSetWindowAttribute(handle, Win32Interop.DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, dwmBdVal, 4); Marshal.FreeHGlobal(dwmBdVal); - IntPtr dwmTbVal = Marshal.AllocHGlobal(4); + nint dwmTbVal = Marshal.AllocHGlobal(4); Marshal.WriteInt32(dwmTbVal, unchecked((int)0xFFFFFFFE)); Win32Interop.DwmSetWindowAttribute(handle, Win32Interop.DWMWINDOWATTRIBUTE.DWMWA_CAPTION_COLOR, dwmTbVal, 4); Marshal.FreeHGlobal(dwmTbVal); @@ -82,5 +84,22 @@ public static string ExtRemover(string FilePath) FilePath = FilePath.Remove(FilePath.LastIndexOf('.')); return FilePath; } + public static void StartProcess(string FilePath, string Arguments = "") + { + Task.Run(() => + { + try + { + Process.Start(new ProcessStartInfo() + { + FileName = FilePath, + Arguments = Arguments, + UseShellExecute = true, + WorkingDirectory = Environment.GetEnvironmentVariable("USERPROFILE") + }); + } + catch { } + }); + } } } \ No newline at end of file diff --git a/SuperLauncher/ShellView.cs b/SuperLauncher/ShellView.cs index de3b879..9fd4312 100644 --- a/SuperLauncher/ShellView.cs +++ b/SuperLauncher/ShellView.cs @@ -1,4 +1,5 @@ using System; +using System.Drawing; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -14,11 +15,12 @@ public partial class ShellView : Form private readonly ModernLauncherExplorerButtons MButtons = new(); private ComInterop.IExplorerBrowser Browser; private uint AdviseCookie; - private IntPtr ParentFolder; + private nint ParentFolder; private uint NavLogCount = 0; private uint NavLogPosition = 0; private bool BackPressed = false; private bool ForwardPressed = false; + private string CurrentFolder = ""; public ShellView(string InitialPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") { this.InitialPath = InitialPath; @@ -56,7 +58,7 @@ private void ShellView_Load(object sender, EventArgs e) fFlags = ComInterop.FOLDERFLAGS.FWF_NONE, ViewMode = ComInterop.FOLDERVIEWMODE.FVM_AUTO }); - uint hresult = Win32Interop.SHParseDisplayName(InitialPath, IntPtr.Zero, out IntPtr ppidl, 0, out _); + uint hresult = Win32Interop.SHParseDisplayName(InitialPath, nint.Zero, out nint ppidl, 0, out _); if (hresult == 0) { Browser.BrowseToIDList(ppidl, ComInterop.BROWSETOFLAGS.SBSP_ABSOLUTE); @@ -64,7 +66,7 @@ private void ShellView_Load(object sender, EventArgs e) } else { - Win32Interop.SHParseDisplayName("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", IntPtr.Zero, out ppidl, 0, out _); + Win32Interop.SHParseDisplayName("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", nint.Zero, out ppidl, 0, out _); Browser.BrowseToIDList(ppidl, ComInterop.BROWSETOFLAGS.SBSP_ABSOLUTE); Win32Interop.ILFree(ppidl); } @@ -77,17 +79,17 @@ public ExplorerBrowserEvents(ShellView shellView) { ShellView = shellView; } - public uint OnNavigationPending([In] IntPtr pidlFolder) + public uint OnNavigationPending([In] nint pidlFolder) { return 0; } - public uint OnViewCreated([In] IntPtr psv) + public uint OnViewCreated([In] nint psv) { return 0; } - public uint OnNavigationComplete([In] IntPtr pidlFolder) + public uint OnNavigationComplete([In] nint pidlFolder) { - ShellView.Browser.GetCurrentView(Guid.Parse("000214E3-0000-0000-C000-000000000046"), out IntPtr ppv); + ShellView.Browser.GetCurrentView(Guid.Parse("000214E3-0000-0000-C000-000000000046"), out nint ppv); ShellView.ComShellView = (ComInterop.IShellView)Marshal.GetTypedObjectForIUnknown(ppv, typeof(ComInterop.IShellView)); ShellView.Browser.GetCurrentView(Guid.Parse("cde725b0-ccc9-4519-917e-325d72fab4ce"), out ppv); ShellView.ComFolderView = (ComInterop.IFolderView)Marshal.GetTypedObjectForIUnknown(ppv, typeof(ComInterop.IFolderView)); @@ -97,7 +99,7 @@ public uint OnNavigationComplete([In] IntPtr pidlFolder) ShellView.MButtons.Up.IsEnabled = !(ppv == ShellView.ParentFolder); ShellView.ParentFolder = ppv; ShellView.Text = displayName; - ShellView.txtNav.Text = absoluteName; + ShellView.txtNav.Text = ShellView.CurrentFolder = absoluteName; if (ShellView.BackPressed) { ShellView.NavLogPosition--; @@ -124,7 +126,7 @@ public uint OnNavigationComplete([In] IntPtr pidlFolder) ShellView.MButtons.Forward.IsEnabled = (ShellView.NavLogPosition < ShellView.NavLogCount); return 0; } - public uint OnNavigationFailed([In] IntPtr pidlFolder) + public uint OnNavigationFailed([In] nint pidlFolder) { return 0; } @@ -132,12 +134,12 @@ public uint OnNavigationFailed([In] IntPtr pidlFolder) private void BtnBack_Click(object sender, EventArgs e) { BackPressed = true; - Browser.BrowseToIDList(IntPtr.Zero, ComInterop.BROWSETOFLAGS.SBSP_NAVIGATEBACK); + Browser.BrowseToIDList(nint.Zero, ComInterop.BROWSETOFLAGS.SBSP_NAVIGATEBACK); } private void BtnForward_Click(object sender, EventArgs e) { ForwardPressed = true; - Browser.BrowseToIDList(IntPtr.Zero, ComInterop.BROWSETOFLAGS.SBSP_NAVIGATEFORWARD); + Browser.BrowseToIDList(nint.Zero, ComInterop.BROWSETOFLAGS.SBSP_NAVIGATEFORWARD); } private void BtnNavUp_Click(object sender, EventArgs e) { @@ -148,7 +150,7 @@ private void ShellView_KeyDown(object sender, KeyEventArgs e) if (e.KeyCode == Keys.Enter) { e.Handled = true; - uint hresult = Win32Interop.SHParseDisplayName(txtNav.Text, IntPtr.Zero, out IntPtr ppidl, 0, out _); + uint hresult = Win32Interop.SHParseDisplayName(txtNav.Text, nint.Zero, out nint ppidl, 0, out _); if (hresult == 0) { Browser.BrowseToIDList(ppidl, ComInterop.BROWSETOFLAGS.SBSP_ABSOLUTE); @@ -163,7 +165,7 @@ private void ShellView_KeyDown(object sender, KeyEventArgs e) private void ShellView_Resize(object sender, EventArgs e) { if (Browser == null) return; - Browser.SetRect(IntPtr.Zero, new Win32Interop.RECT() + Browser.SetRect(nint.Zero, new Win32Interop.RECT() { top = 36, left = 0, @@ -178,7 +180,12 @@ private void ShellView_FormClosing(object sender, FormClosingEventArgs e) } private void MIOpenWith_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { - + string processPath = (string)e.ClickedItem.Tag; + ComFolderView.GetFocusedItem(out int piItem); + ComFolderView.Item(piItem, out nint ppidl); + Win32Interop.SHGetNameFromIDList(ppidl, Win32Interop.SIGDN.SIGDN_NORMALDISPLAY, out string filePath); + if (Directory.Exists(CurrentFolder)) filePath = Path.Combine(CurrentFolder, filePath); + Shared.StartProcess(processPath, filePath); } private void MIOpenWith_DropDownOpening(object sender, EventArgs e) { @@ -188,7 +195,10 @@ private void MIOpenWith_DropDownOpening(object sender, EventArgs e) foreach (string filePath in Settings.Default.FileList) { if (!File.Exists(filePath)) continue; - ToolStripItem item = MIOpenWith.DropDownItems.Add(Shared.ExtRemover(filePath)); + ToolStripItem item = MIOpenWith.DropDownItems.Add( + Shared.ExtRemover(filePath), + Icon.ExtractAssociatedIcon(filePath).ToBitmap() + ); item.Tag = filePath; } } diff --git a/SuperLauncher/Win32Interop.cs b/SuperLauncher/Win32Interop.cs index 84c55b6..21688bf 100644 --- a/SuperLauncher/Win32Interop.cs +++ b/SuperLauncher/Win32Interop.cs @@ -7,41 +7,41 @@ namespace SuperLauncher public static class Win32Interop { [DllImport("Dwmapi.dll")] - public static extern uint DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] IntPtr pvAttribute, uint cbAttribute); + public static extern uint DwmSetWindowAttribute(nint hwnd, DWMWINDOWATTRIBUTE dwAttribute, [In] nint pvAttribute, uint cbAttribute); [DllImport("Shell32.dll")] - public static extern uint SHBindToParent(IntPtr pidl, Guid riid, out IntPtr ppv, out IntPtr ppidlLast); + public static extern uint SHBindToParent(nint pidl, Guid riid, out nint ppv, out nint ppidlLast); [DllImport("Shell32.dll")] - public static extern void SHGetNameFromIDList(IntPtr pidl, SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName); + public static extern void SHGetNameFromIDList(nint pidl, SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName); [DllImport("Shell32.dll")] - public static extern void ILFree(IntPtr pidl); + public static extern void ILFree(nint pidl); [DllImport("Shell32.dll")] - public static extern uint SHParseDisplayName([MarshalAs(UnmanagedType.LPWStr)] string pszName, [Optional] IntPtr pbc, out IntPtr ppidl, uint sfgaoIn, out IntPtr psfgaoOut); + public static extern uint SHParseDisplayName([MarshalAs(UnmanagedType.LPWStr)] string pszName, [Optional] nint pbc, out nint ppidl, uint sfgaoIn, out nint psfgaoOut); [DllImport("User32.dll")] public static extern short GetKeyState(int nVirtKey); [DllImport("User32.dll")] public static extern bool GetCursorPos(out POINT lpPoint); [DllImport("User32.dll")] - public static extern bool GetMonitorInfo(IntPtr hMonitor, out MONITORINFO lpmi); + public static extern bool GetMonitorInfo(nint hMonitor, out MONITORINFO lpmi); [DllImport("User32.dll")] public static extern bool ChangeWindowMessageFilter(uint message, uint action); [DllImport("User32.dll")] - public static extern IntPtr MonitorFromWindow(IntPtr hWnd, MonitorFromWindowFlags dwFlags); + public static extern nint MonitorFromWindow(nint hWnd, MonitorFromWindowFlags dwFlags); [DllImport("User32.dll")] - public static extern bool InvalidateRect(IntPtr hWnd, IntPtr Rect, bool Erase); + public static extern bool InvalidateRect(nint hWnd, nint Rect, bool Erase); [DllImport("User32.dll")] public static extern uint RegisterWindowMessage(string lpString); [DllImport("user32.dll")] - public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); + public static extern bool RegisterHotKey(nint hWnd, int id, uint fsModifiers, uint vk); [DllImport("user32.dll")] - private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); + private static extern int SendMessage(nint hWnd, int wMsg, nint wParam, nint lParam); [DllImport("user32.dll")] - public static extern long SetWindowLong(IntPtr hWnd, SetWindowLongIndex nIndex, ExtendedWindowStyles dwNewLong); + public static extern long SetWindowLong(nint hWnd, SetWindowLongIndex nIndex, ExtendedWindowStyles dwNewLong); [DllImport("user32.dll", SetLastError = true)] - private static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr hIcon, int cxWidth, int cyHeight, int istepIfAniCur, IntPtr hbrFlickerFreeDraw, int diFlags); + private static extern bool DrawIconEx(nint hdc, int xLeft, int yTop, nint hIcon, int cxWidth, int cyHeight, int istepIfAniCur, nint hbrFlickerFreeDraw, int diFlags); [DllImport("gdi32.dll")] - private static extern IntPtr CreateSolidBrush(uint crColor); + private static extern nint CreateSolidBrush(uint crColor); [DllImport("user32.dll")] - internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); + internal static extern int SetWindowCompositionAttribute(nint hwnd, ref WindowCompositionAttributeData data); [StructLayout(LayoutKind.Sequential)] public struct RECT { @@ -111,7 +111,7 @@ public struct AccentPolicy public struct WindowCompositionAttributeData { public WindowCompositionAttribute Attribute; - public IntPtr Data; + public nint Data; public int SizeOfData; } public enum DWMWINDOWATTRIBUTE @@ -196,7 +196,7 @@ public static Bitmap ToBitmapAlpha(this Icon Icon, int Width, int Height, Color Icon rsIcon = new(Icon, Width, Height); Bitmap bmIcon = new(Width, Height); Graphics g = Graphics.FromImage(bmIcon); - IntPtr hdc = g.GetHdc(); + nint hdc = g.GetHdc(); DrawIconEx(hdc, 0, 0, rsIcon.Handle, Width, Height, 0, CreateSolidBrush((uint)ColorTranslator.ToWin32(Background)), 0x3); g.ReleaseHdc(hdc); return bmIcon; @@ -206,7 +206,7 @@ public static Bitmap ToBitmapAlpha(this Icon Icon, int Width, int Height) return ToBitmapAlpha(Icon, Width, Height, Color.White); } /* - public static void EnableBlur(IntPtr Handle, uint BlurOpacity = 100, uint BlurBackgroundColor = 0x990000) + public static void EnableBlur(nint Handle, uint BlurOpacity = 100, uint BlurBackgroundColor = 0x990000) { var accent = new AccentPolicy { diff --git a/SuperLauncherBootstrap/Bootstrap.cs b/SuperLauncherBootstrap/Bootstrap.cs index 105bf5c..f0579c8 100644 --- a/SuperLauncherBootstrap/Bootstrap.cs +++ b/SuperLauncherBootstrap/Bootstrap.cs @@ -17,16 +17,16 @@ public static class Bootstrap private static readonly string TargetMessage = "ShowSuperLauncher"; private static readonly string SelfPath = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location)!; [DllImport("User32.dll")] - private static extern uint SendNotifyMessage(IntPtr hWnd, uint Msg, uint wParam, uint lParam); + private static extern uint SendNotifyMessage(nint hWnd, uint Msg, uint wParam, uint lParam); [DllImport("User32.dll")] private static extern uint RegisterWindowMessage(string lpString); [DllImport("User32.dll")] - private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); + private static extern nint FindWindow(string lpClassName, string lpWindowName); [STAThread] public static void Main() { - IntPtr existingWindow = FindWindow(null, TargetWindowName); - if (existingWindow != IntPtr.Zero) + nint existingWindow = FindWindow(null, TargetWindowName); + if (existingWindow != nint.Zero) { SendNotifyMessage(existingWindow, RegisterWindowMessage(TargetMessage), 0x0, 0x0); return;