清理代码

This commit is contained in:
筱傑 2021-04-29 13:17:26 +08:00
parent 077b8b1e13
commit c7ac1341cc
7 changed files with 9 additions and 22 deletions

View File

@ -1,9 +1,4 @@
using System; using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization; using System.Xml.Serialization;
namespace KeyGo namespace KeyGo
@ -29,7 +24,6 @@ namespace KeyGo
/// </value> /// </value>
public bool CloseToHide { get; set; } = true; public bool CloseToHide { get; set; } = true;
/// <summary> /// <summary>
/// Loads the XML. /// Loads the XML.
/// </summary> /// </summary>

View File

@ -151,6 +151,7 @@ namespace KeyGo
[DllImport("User32.dll")] [DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")] [DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int cmdShow); private static extern bool ShowWindow(IntPtr hWnd, int cmdShow);

View File

@ -5,7 +5,7 @@ using System.Windows.Forms;
namespace KeyGo namespace KeyGo
{ {
public class AppHotKey public static class AppHotKey
{ {
/// <summary> /// <summary>
/// 注册热键 /// 注册热键
@ -17,14 +17,7 @@ namespace KeyGo
public static void RegKey(IntPtr hwnd, int hotKey_id, KeyModifiers keyModifiers, Keys key) public static void RegKey(IntPtr hwnd, int hotKey_id, KeyModifiers keyModifiers, Keys key)
{ {
if (!RegisterHotKey(hwnd, hotKey_id, keyModifiers, key)) if (!RegisterHotKey(hwnd, hotKey_id, keyModifiers, key))
{
throw new Win32Exception(); throw new Win32Exception();
//int code = Marshal.GetLastWin32Error();
//if (code == 1409)
// MessageBox.Show("热键被占用!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
//else
// MessageBox.Show("注册热键失败!错误代码:" + code.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
/// <summary> /// <summary>
@ -38,7 +31,6 @@ namespace KeyGo
UnregisterHotKey(hwnd, hotKey_id); UnregisterHotKey(hwnd, hotKey_id);
} }
//如果函数执行成功返回值不为0。 //如果函数执行成功返回值不为0。
//如果函数执行失败返回值为0。要得到扩展错误信息调用GetLastError。 //如果函数执行失败返回值为0。要得到扩展错误信息调用GetLastError。
[DllImport("user32.dll", SetLastError = true)] [DllImport("user32.dll", SetLastError = true)]

View File

@ -12,6 +12,7 @@ namespace KeyGo
} }
public HotKeyItem HotKeyItem { get; set; } public HotKeyItem HotKeyItem { get; set; }
private void FormHotKey_Load(object sender, EventArgs e) private void FormHotKey_Load(object sender, EventArgs e)
{ {
if (HotKeyItem != null) if (HotKeyItem != null)
@ -110,6 +111,5 @@ namespace KeyGo
TxtStartupPath.Text = frm.FileName; TxtStartupPath.Text = frm.FileName;
} }
} }
} }
} }

View File

@ -325,6 +325,6 @@ namespace KeyGo
} }
} }
#endregion #endregion
} }
} }