📄 shellexecute.cs
字号:
using System;
using System.Runtime.InteropServices;
using Addot.Internals;
namespace Addot.Win32
{
public class ShellExecute
{
private struct SHELLEXECUTEEX
{
public UInt32 cbSize;
public UInt32 fMask;
public IntPtr hwnd;
public IntPtr lpVerb;
public IntPtr lpFile;
public IntPtr lpParameters;
public IntPtr lpDirectory;
public int nShow;
public IntPtr hInstApp;
// Optional members
public IntPtr lpIDList;
public IntPtr lpClass;
public IntPtr hkeyClass;
public UInt32 dwHotKey;
public IntPtr hIcon;
public IntPtr hProcess;
}
[DllImport("coredll")]
private extern static int ShellExecuteEx( ref SHELLEXECUTEEX ex );
public static void Execute(string fileName)
{
int size = fileName.Length * 2 + 2;
IntPtr data = Memory.LocalAlloc(0x40, size);
Marshal.Copy(System.Text.Encoding.Unicode.GetBytes(fileName), 0, data, size - 2);
SHELLEXECUTEEX shellExe = new SHELLEXECUTEEX();
shellExe.cbSize = (uint)Marshal.SizeOf(shellExe);
shellExe.dwHotKey = 0;
shellExe.fMask = 0;
shellExe.hIcon = IntPtr.Zero;
shellExe.hInstApp = IntPtr.Zero;
shellExe.hProcess = IntPtr.Zero;;
shellExe.lpClass = IntPtr.Zero;
shellExe.lpDirectory = IntPtr.Zero;
shellExe.lpIDList = IntPtr.Zero;
shellExe.lpParameters = IntPtr.Zero;
shellExe.lpVerb = IntPtr.Zero;
shellExe.nShow = 0;
shellExe.lpFile = data;
ShellExecuteEx(ref shellExe);
Memory.LocalFree(data);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -