一.判断程序是否以管理员权限运行 using System.Security.Principal; public bool IsAdministrator() { WindowsIdentity current = WindowsIdentity.GetCurrent(); WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current); return windowsPrincipal.IsInRole(WindowsBuilt…
1.右键→打开方式→选择默认程序→选择winform程序 2.修改Program.cs 判断注册的事件是否存在,如果不存在则运行实例,并把参数传入MainForm里,如果存在则把参数写到txt文件中,然后发事件,退出 using Microsoft.Win32; using System; using System.Collections.Generic; using System.IO; using System.Threading; using System.Windows.Forms; n…
//调用Windows API 展示窗口到最前端 SwitchToThisWindow(this.Handle, true);//窗体的句柄 this.Handle SwitchToThisWindow (user32) Summary Switches focus to a specified window and brings it to the foreground. C# Signature: [DllImport("user32.dll", SetLastErro…
public static class ComponentHelper<T> where T : Control { public static bool HaveEventHandler(T control, string eventName, string methodName) { //获取Button类定义的所有事件的信息 PropertyInfo pi = (typeof(T)).GetProperty("Events", BindingFlags.Instanc…