private static bool ConsoleCtrlCheck(WindowsLaunch.CtrlTypes ctrlType) { bool flag = false; switch (ctrlType) { case WindowsLaunch.CtrlTypes.CTRL_C_EVENT: flag = true; break; case WindowsLaunch.CtrlTypes.CTRL_BREAK_EVENT: flag = true; break; case WindowsLaunch.CtrlTypes.CTRL_CLOSE_EVENT: flag = true; break; case WindowsLaunch.CtrlTypes.CTRL_LOGOFF_EVENT: case WindowsLaunch.CtrlTypes.CTRL_SHUTDOWN_EVENT: flag = true; break; } if (flag) { SocialAPI.Shutdown(); } return true; }
private static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs sargs) { string resourceName = new AssemblyName(sargs.Name).Name + ".dll"; string text = Array.Find <string>(typeof(Program).Assembly.GetManifestResourceNames(), (string element) => element.EndsWith(resourceName)); if (text == null) { return(null); } Assembly result; using (Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text)) { byte[] array = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(array, 0, array.Length); result = Assembly.Load(array); } return(result); }; #if SERVER WindowsLaunch._handleRoutine = new WindowsLaunch.HandlerRoutine(WindowsLaunch.ConsoleCtrlCheck); WindowsLaunch.SetConsoleCtrlHandler(WindowsLaunch._handleRoutine, true); #endif Program.LaunchGame(args, false); }
private static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += (ResolveEventHandler)((sender, sargs) => { string resourceName = new AssemblyName(sargs.Name).Name + ".dll"; string name = Array.Find <string>(typeof(Program).Assembly.GetManifestResourceNames(), (Predicate <string>)(element => element.EndsWith(resourceName))); if (name == null) { return((Assembly)null); } using (Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name)) { byte[] numArray = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(numArray, 0, numArray.Length); return(Assembly.Load(numArray)); } }); WindowsLaunch._handleRoutine = new WindowsLaunch.HandlerRoutine(WindowsLaunch.ConsoleCtrlCheck); WindowsLaunch.SetConsoleCtrlHandler(WindowsLaunch._handleRoutine, true); Program.LaunchGame(args, false); }
public static extern bool SetConsoleCtrlHandler(WindowsLaunch.HandlerRoutine Handler, bool Add);