📄 shellhelper.cs
字号:
namespace Imps.Client.Utils
{
using Microsoft.Win32;
using System;
using System.Runtime.InteropServices;
using System.Text;
public static class ShellHelper
{
public static void ApplicationExit()
{
ApplicationExit(0);
}
public static void ApplicationExit(int exitCode)
{
try
{
Environment.Exit(exitCode);
}
catch
{
}
}
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int FindExecutable(string filename, string directory, ref string result);
private static string ParseString(string value)
{
if (value.Substring(0, 1) == "\"")
{
int index = value.IndexOf("\"", 1);
return value.Substring(0, index + 1);
}
return value.Split(new char[] { ' ' })[0];
}
[DllImport("shell32.dll", CharSet=CharSet.Auto)]
public static extern int ShellExecute(IntPtr hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
public static void StartUri(Uri uri)
{
StartUrl(uri.AbsoluteUri);
}
public static void StartUrl(string url)
{
try
{
StringBuilder builder = new StringBuilder(ParseString((string) Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false).GetValue(string.Empty, string.Empty)));
builder.Append(" ");
builder.Append(url);
WinExec(builder.ToString(), 5);
}
catch
{
try
{
StringBuilder builder2 = new StringBuilder(ParseString((string) Registry.ClassesRoot.OpenSubKey(@"Applications\iexplore.exe\shell\open\command", false).GetValue(string.Empty, string.Empty)));
builder2.Append(" ");
builder2.Append(url);
WinExec(builder2.ToString(), 5);
}
catch
{
}
}
}
[DllImport("kernel32.dll")]
public static extern int WinExec(string lpCmdLine, int nCmdShow);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -