/////////////////////////////////////////////////////////////////////// private static bool Open( ref string error ) { try { if (VersionOps.IsWindowsOperatingSystem()) { if (UnsafeNativeMethods.AllocConsole()) { return(true); } else { error = "failed to allocate console"; } } else { error = "not implemented"; } } catch (Exception e) { error = e.ToString(); } return(false); }
public static void Init() { UnsafeNativeMethods.AllocConsole(); IntPtr hwnd = UnsafeNativeMethods.GetConsoleWindow(); IntPtr hSystemMenu = UnsafeNativeMethods.GetSystemMenu(hwnd, false); UnsafeNativeMethods.EnableMenuItem(hSystemMenu, UnsafeNativeMethods.SC_CLOSE, (uint)(UnsafeNativeMethods.MF_ENABLED | (false ? UnsafeNativeMethods.MF_ENABLED : UnsafeNativeMethods.MF_GRAYED))); }