diff --git a/NativeDllImport/BringWindowToTop.cs b/NativeDllImport/BringWindowToTop.cs index 0530961..eafceee 100644 --- a/NativeDllImport/BringWindowToTop.cs +++ b/NativeDllImport/BringWindowToTop.cs @@ -41,22 +41,28 @@ namespace SystemTrayMenu.DllImports } } - [DllImport("user32.dll")] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool IsIconic(IntPtr hWnd); - [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr GetForegroundWindow(); - [DllImport("user32.dll")] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern uint GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId); - [DllImport("kernel32.dll")] + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern uint GetCurrentThreadId(); - [DllImport("user32.dll")] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool AttachThreadInput(uint idAttach, uint idAttachTo, bool fAttach); - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool BringWindowToTop(IntPtr hWnd); } } diff --git a/NativeDllImport/CreatePopupMenu.cs b/NativeDllImport/CreatePopupMenu.cs index f00744f..a883928 100644 --- a/NativeDllImport/CreatePopupMenu.cs +++ b/NativeDllImport/CreatePopupMenu.cs @@ -19,6 +19,7 @@ namespace SystemTrayMenu.DllImports // The CreatePopupMenu function creates a drop-down menu, submenu, or shortcut menu. The menu is initially empty. You can insert or append menu items by using the InsertMenuItem function. You can also use the InsertMenu function to insert menu items and the AppendMenu function to append menu items. [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr CreatePopupMenu(); } } diff --git a/NativeDllImport/DestroyIcon.cs b/NativeDllImport/DestroyIcon.cs index 8429793..a5c51ea 100644 --- a/NativeDllImport/DestroyIcon.cs +++ b/NativeDllImport/DestroyIcon.cs @@ -17,7 +17,8 @@ namespace SystemTrayMenu.DllImports _ = DestroyIcon(hIcon); } - [DllImport("User32.dll")] + [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int DestroyIcon(IntPtr hIcon); } } diff --git a/NativeDllImport/DestroyMenu.cs b/NativeDllImport/DestroyMenu.cs index a8b1819..819e640 100644 --- a/NativeDllImport/DestroyMenu.cs +++ b/NativeDllImport/DestroyMenu.cs @@ -19,6 +19,7 @@ namespace SystemTrayMenu.DllImports // The DestroyMenu function destroys the specified menu and frees any memory that the menu occupies. [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool DestroyMenu(IntPtr hMenu); } } diff --git a/NativeDllImport/FindExecuteable.cs b/NativeDllImport/FindExecuteable.cs index 7953b3d..70d33f1 100644 --- a/NativeDllImport/FindExecuteable.cs +++ b/NativeDllImport/FindExecuteable.cs @@ -17,7 +17,8 @@ namespace SystemTrayMenu.DllImports _ = FindExecutable(lpFile, lpDirectory, lpResult); } - [DllImport("shell32.dll", CharSet = CharSet.Unicode)] + [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult); } } diff --git a/NativeDllImport/FindWindow.cs b/NativeDllImport/FindWindow.cs index 046fcec..1995ddc 100644 --- a/NativeDllImport/FindWindow.cs +++ b/NativeDllImport/FindWindow.cs @@ -18,6 +18,7 @@ namespace SystemTrayMenu.DllImports } [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); } } diff --git a/NativeDllImport/GetDeviceCaps.cs b/NativeDllImport/GetDeviceCaps.cs index 64bf419..18bb6b6 100644 --- a/NativeDllImport/GetDeviceCaps.cs +++ b/NativeDllImport/GetDeviceCaps.cs @@ -17,7 +17,8 @@ namespace SystemTrayMenu.DllImports return GetDeviceCaps(hdc, nIndex); } - [DllImport("gdi32.dll")] + [DllImport("gdi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int GetDeviceCaps(IntPtr hdc, int nIndex); } } diff --git a/NativeDllImport/GetIcon.cs b/NativeDllImport/GetIcon.cs index 9dd9a74..2b57571 100644 --- a/NativeDllImport/GetIcon.cs +++ b/NativeDllImport/GetIcon.cs @@ -40,7 +40,8 @@ namespace SystemTrayMenu.DllImports /// i. /// flags. /// IntPtr. - [DllImport("comctl32")] + [DllImport("comctl32", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern IntPtr ImageList_GetIcon( IntPtr himl, int i, diff --git a/NativeDllImport/GetMenuDefaultItem.cs b/NativeDllImport/GetMenuDefaultItem.cs index 567ac9f..3c86d84 100644 --- a/NativeDllImport/GetMenuDefaultItem.cs +++ b/NativeDllImport/GetMenuDefaultItem.cs @@ -19,6 +19,7 @@ namespace SystemTrayMenu.DllImports // Determines the default menu item on the specified menu [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int GetMenuDefaultItem(IntPtr hMenu, bool fByPos, uint gmdiFlags); } } diff --git a/NativeDllImport/IsTouchEnabled.cs b/NativeDllImport/IsTouchEnabled.cs index 6a15f83..2fc9d28 100644 --- a/NativeDllImport/IsTouchEnabled.cs +++ b/NativeDllImport/IsTouchEnabled.cs @@ -19,7 +19,8 @@ namespace SystemTrayMenu.DllImports return maxTouches > 0; } - [DllImport("user32.dll")] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int GetSystemMetrics(int nIndex); } } diff --git a/NativeDllImport/RegisterHotKey.cs b/NativeDllImport/RegisterHotKey.cs index b0c8d67..0d1d2e7 100644 --- a/NativeDllImport/RegisterHotKey.cs +++ b/NativeDllImport/RegisterHotKey.cs @@ -33,18 +33,22 @@ namespace SystemTrayMenu.DllImports return GetKeyNameText(lParam, lpString, nSize); } - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint virtualKeyCode); - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool UnregisterHotKey(IntPtr hWnd, int id); - [DllImport("user32.dll", SetLastError = true)] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern uint MapVirtualKey(uint uCode, uint uMapType); [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int GetKeyNameText(uint lParam, [Out] StringBuilder lpString, int nSize); } } diff --git a/NativeDllImport/SHAppBarMessage.cs b/NativeDllImport/SHAppBarMessage.cs index 614b0a2..daaae25 100644 --- a/NativeDllImport/SHAppBarMessage.cs +++ b/NativeDllImport/SHAppBarMessage.cs @@ -40,10 +40,11 @@ namespace SystemTrayMenu.DllImports return SHAppBarMessage(dwMessage, ref pData); } - [DllImport("shell32.dll", SetLastError = true)] + [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr SHAppBarMessage(ABM dwMessage, [In] ref APPBARDATA pData); - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct APPBARDATA { public uint cbSize; @@ -54,7 +55,7 @@ namespace SystemTrayMenu.DllImports public int lParam; } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct RECT { public int left; diff --git a/NativeDllImport/SHGetDesktopFolder.cs b/NativeDllImport/SHGetDesktopFolder.cs index ae3cde9..5de7e2b 100644 --- a/NativeDllImport/SHGetDesktopFolder.cs +++ b/NativeDllImport/SHGetDesktopFolder.cs @@ -18,7 +18,8 @@ namespace SystemTrayMenu.DllImports } // Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace. - [DllImport("shell32.dll")] + [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int SHGetDesktopFolder(out IntPtr ppshf); } } diff --git a/NativeDllImport/SHGetFileInfo.cs b/NativeDllImport/SHGetFileInfo.cs index a0897e7..f12bc31 100644 --- a/NativeDllImport/SHGetFileInfo.cs +++ b/NativeDllImport/SHGetFileInfo.cs @@ -29,7 +29,8 @@ namespace SystemTrayMenu.DllImports uFlags); } - [DllImport("Shell32.dll", CharSet = CharSet.Unicode)] + [DllImport("Shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, @@ -38,6 +39,7 @@ namespace SystemTrayMenu.DllImports uint uFlags); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + internal struct SHFILEINFO { public const int NAMESIZE = 80; diff --git a/NativeDllImport/SHGetFolderPath.cs b/NativeDllImport/SHGetFolderPath.cs index 13683c0..9d57e92 100644 --- a/NativeDllImport/SHGetFolderPath.cs +++ b/NativeDllImport/SHGetFolderPath.cs @@ -18,7 +18,8 @@ namespace SystemTrayMenu.DllImports return SHGetFolderPath(hwndOwner, nFolder, hToken, dwFlags, lpszPath); } - [DllImport("shfolder.dll", CharSet = CharSet.Unicode)] + [DllImport("shfolder.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath); } } diff --git a/NativeDllImport/SetProcessDPIAware.cs b/NativeDllImport/SetProcessDPIAware.cs index 1da52b2..39a50ce 100644 --- a/NativeDllImport/SetProcessDPIAware.cs +++ b/NativeDllImport/SetProcessDPIAware.cs @@ -16,7 +16,8 @@ namespace SystemTrayMenu.DllImports _ = SetProcessDPIAware(); } - [DllImport("user32.dll")] + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool SetProcessDPIAware(); } } diff --git a/NativeDllImport/ShowInactiveTopmost.cs b/NativeDllImport/ShowInactiveTopmost.cs index 93645df..0b631f8 100644 --- a/NativeDllImport/ShowInactiveTopmost.cs +++ b/NativeDllImport/ShowInactiveTopmost.cs @@ -32,7 +32,8 @@ namespace SystemTrayMenu.DllImports } } - [DllImport("user32.dll", EntryPoint = "SetWindowPos")] + [DllImport("user32.dll", EntryPoint = "SetWindowPos", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern bool SetWindowPos( int hWnd, // Window handle int hWndInsertAfter, // Placement-order handle diff --git a/NativeDllImport/ShowWindow.cs b/NativeDllImport/ShowWindow.cs index 82f0a10..2f144be 100644 --- a/NativeDllImport/ShowWindow.cs +++ b/NativeDllImport/ShowWindow.cs @@ -12,7 +12,8 @@ namespace SystemTrayMenu.DllImports /// public static partial class NativeMethods { - [DllImport("user32.dll")] - private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + + private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); } } diff --git a/NativeDllImport/StrCmpLogicalW.cs b/NativeDllImport/StrCmpLogicalW.cs index 631f6e4..d8437e4 100644 --- a/NativeDllImport/StrCmpLogicalW.cs +++ b/NativeDllImport/StrCmpLogicalW.cs @@ -16,7 +16,8 @@ namespace SystemTrayMenu.DllImports return StrCmpLogicalW(x, y); } - [DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] + [DllImport("shlwapi.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int StrCmpLogicalW(string x, string y); } } diff --git a/NativeDllImport/StrRetToBuf.cs b/NativeDllImport/StrRetToBuf.cs index f960948..7fca0b0 100644 --- a/NativeDllImport/StrRetToBuf.cs +++ b/NativeDllImport/StrRetToBuf.cs @@ -19,7 +19,8 @@ namespace SystemTrayMenu.DllImports } // Takes a STRRET structure returned by IShellFolder::GetDisplayNameOf, converts it to a string, and places the result in a buffer. - [DllImport("shlwapi.dll", EntryPoint = "StrRetToBuf", ExactSpelling = false, CharSet = CharSet.Unicode, SetLastError = true)] + [DllImport("shlwapi.dll", EntryPoint = "StrRetToBuf", ExactSpelling = false, SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int StrRetToBuf(IntPtr pstr, IntPtr pidl, StringBuilder pszBuf, int cchBuf); } } diff --git a/NativeDllImport/TrackPopupMenuEx.cs b/NativeDllImport/TrackPopupMenuEx.cs index 0a13da6..b8a9104 100644 --- a/NativeDllImport/TrackPopupMenuEx.cs +++ b/NativeDllImport/TrackPopupMenuEx.cs @@ -54,7 +54,8 @@ namespace SystemTrayMenu.DllImports } // The TrackPopupMenuEx function displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu. The shortcut menu can appear anywhere on the screen. - [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Unicode)] + [DllImport("user32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] + private static extern uint TrackPopupMenuEx(IntPtr hmenu, TPM flags, int x, int y, IntPtr hwnd, IntPtr lptpm); } } diff --git a/Packaging/Package.appxmanifest b/Packaging/Package.appxmanifest index c453792..95c84c5 100644 --- a/Packaging/Package.appxmanifest +++ b/Packaging/Package.appxmanifest @@ -9,7 +9,7 @@ + Version="1.0.17.0" /> SystemTrayMenu diff --git a/Packaging/Packaging.wapproj b/Packaging/Packaging.wapproj index 6b92653..7156873 100644 --- a/Packaging/Packaging.wapproj +++ b/Packaging/Packaging.wapproj @@ -55,7 +55,7 @@ False True True - x86 + x86|x64 https://github.com/Hofknecht/SystemTrayMenu/releases 0 diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index ac261c3..e1ce45a 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.16.3")] -[assembly: AssemblyFileVersion("1.0.16.3")] +[assembly: AssemblyVersion("1.0.17.0")] +[assembly: AssemblyFileVersion("1.0.17.0")] diff --git a/UserInterface/FolderBrowseDialog/NativeMethods.cs b/UserInterface/FolderBrowseDialog/NativeMethods.cs index b855f19..22ecedf 100644 --- a/UserInterface/FolderBrowseDialog/NativeMethods.cs +++ b/UserInterface/FolderBrowseDialog/NativeMethods.cs @@ -127,7 +127,8 @@ namespace SystemTrayMenu.UserInterface.FolderBrowseDialog uint Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder); } - [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern int SHCreateItemFromParsingName( [MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, diff --git a/UserInterface/ShellContextMenu/ShellContextMenu.cs b/UserInterface/ShellContextMenu/ShellContextMenu.cs index f62f2c5..13140da 100644 --- a/UserInterface/ShellContextMenu/ShellContextMenu.cs +++ b/UserInterface/ShellContextMenu/ShellContextMenu.cs @@ -1122,7 +1122,7 @@ namespace SystemTrayMenu.Utilities return oParentFolder; } - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] private struct CWPSTRUCT { public IntPtr Lparam; @@ -1133,6 +1133,7 @@ namespace SystemTrayMenu.Utilities // Contains extended information about a shortcut menu command [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + private struct CMINVOKECOMMANDINFOEX { public int CbSize; @@ -1160,6 +1161,7 @@ namespace SystemTrayMenu.Utilities // Contains information about a menu item [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + private struct MENUITEMINFO { private readonly int cbSize; @@ -1195,7 +1197,7 @@ namespace SystemTrayMenu.Utilities // A generalized global memory handle used for data transfer operations by the // IAdviseSink, IDataObject, and IOleCache interfaces - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] private struct STGMEDIUM { public TYMED Tymed; @@ -1211,6 +1213,7 @@ namespace SystemTrayMenu.Utilities // Defines the x- and y-coordinates of a point [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + private struct POINT { public int X;