From f2366c0512bd2ba57dbc0a5138c249374b5273b9 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sun, 24 Oct 2021 09:46:38 +0200 Subject: [PATCH] [BUG] Argument Handling #222 --- DataClasses/RowData.cs | 9 +-------- NativeDllImport/GetDeviceCaps.cs | 24 ------------------------ NativeDllImport/GetIcon.cs | 11 ----------- NativeDllImport/GetMenuDefaultItem.cs | 25 ------------------------- 4 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 NativeDllImport/GetDeviceCaps.cs delete mode 100644 NativeDllImport/GetMenuDefaultItem.cs diff --git a/DataClasses/RowData.cs b/DataClasses/RowData.cs index 5d0baa9..bcc822b 100644 --- a/DataClasses/RowData.cs +++ b/DataClasses/RowData.cs @@ -9,7 +9,6 @@ namespace SystemTrayMenu.DataClasses using System.Drawing; using System.IO; using System.Windows.Forms; - using IWshRuntimeLibrary; using SystemTrayMenu.Utilities; using Menu = SystemTrayMenu.UserInterface.Menu; @@ -18,8 +17,6 @@ namespace SystemTrayMenu.DataClasses private static readonly Icon White50PercentageIcon = Properties.Resources.White50Percentage; private static readonly Icon NotFoundIcon = Properties.Resources.NotFound; private static DateTime contextMenuClosed; - private string workingDirectory; - private string arguments; private string text; private Icon icon; @@ -248,7 +245,7 @@ namespace SystemTrayMenu.DataClasses if (!ContainsMenu && (e == null || e.Button == MouseButtons.Left)) { - Log.ProcessStart(TargetFilePathOrig, arguments, false, workingDirectory, true); + Log.ProcessStart(TargetFilePathOrig, string.Empty, false, string.Empty, true); if (!Properties.Settings.Default.StaysOpenWhenItemClicked) { toCloseByOpenItem = true; @@ -280,10 +277,6 @@ namespace SystemTrayMenu.DataClasses } else { - IWshShell shell = new WshShell(); - IWshShortcut lnk = shell.CreateShortcut(TargetFilePath) as IWshShortcut; - arguments = lnk.Arguments; - workingDirectory = lnk.WorkingDirectory; TargetFilePath = resolvedLnkPath; } diff --git a/NativeDllImport/GetDeviceCaps.cs b/NativeDllImport/GetDeviceCaps.cs deleted file mode 100644 index c5c7574..0000000 --- a/NativeDllImport/GetDeviceCaps.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace SystemTrayMenu.DllImports -{ - using System; - using System.Runtime.InteropServices; - - /// - /// wraps the methodcalls to native windows dll's. - /// - public static partial class NativeMethods - { - public static int Gdi32GetDeviceCaps(IntPtr hdc, int nIndex) - { - return GetDeviceCaps(hdc, nIndex); - } - - [DllImport("gdi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - [DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)] - private static extern int GetDeviceCaps(IntPtr hdc, int nIndex); - } -} diff --git a/NativeDllImport/GetIcon.cs b/NativeDllImport/GetIcon.cs index b59ec01..400c1d9 100644 --- a/NativeDllImport/GetIcon.cs +++ b/NativeDllImport/GetIcon.cs @@ -12,7 +12,6 @@ namespace SystemTrayMenu.DllImports /// public static partial class NativeMethods { -#pragma warning disable SA1600 // Elements should be documented public const uint ShgfiIcon = 0x000000100; // get icon public const uint ShgfiSYSICONINDEX = 0x000004000; // get system icon index public const uint ShgfiLINKOVERLAY = 0x000008000; // put a link overlay on icon @@ -22,16 +21,6 @@ namespace SystemTrayMenu.DllImports public const uint FileAttributeDirectory = 0x00000010; public const uint FileAttributeNormal = 0x00000080; public const int IldTransparent = 0x00000001; -#pragma warning restore SA1600 // Elements should be documented - - /// - /// comctl32 ImageList_GetIcon(IntPtr hIcon). - /// - /// hIcon. - public static void Comctl32ImageListGetIcon(IntPtr hIcon) - { - _ = DestroyIcon(hIcon); - } /// /// comctl32 ImageList_GetIcon(IntPtr himl, int i, int flags). diff --git a/NativeDllImport/GetMenuDefaultItem.cs b/NativeDllImport/GetMenuDefaultItem.cs deleted file mode 100644 index a3ed1a4..0000000 --- a/NativeDllImport/GetMenuDefaultItem.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) PlaceholderCompany. All rights reserved. -// - -namespace SystemTrayMenu.DllImports -{ - using System; - using System.Runtime.InteropServices; - - /// - /// wraps the methodcalls to native windows dll's. - /// - public static partial class NativeMethods - { - public static int User32GetMenuDefaultItem(IntPtr hMenu, bool fByPos, uint gmdiFlags) - { - return GetMenuDefaultItem(hMenu, fByPos, gmdiFlags); - } - - // Determines the default menu item on the specified menu - [DllImport("user32", SetLastError = true, CharSet = CharSet.Unicode)] - [DefaultDllImportSearchPaths(DllImportSearchPath.UserDirectories)] - private static extern int GetMenuDefaultItem(IntPtr hMenu, bool fByPos, uint gmdiFlags); - } -}