Exemplo n.º 1
0
        /// <summary>
        /// Attach the calling process to the console of the specified process.
        /// </summary>
        /// <param name="processId">Identifier of the process whose console will be attached.</param>
//		public static void AttachConsole(int processId)
//		{
//			if (!AttachConsole(processId))
//			{
//                int err = Marshal.GetLastWin32Error();
//				throw new IOException(String.Format("Unable to attach console 0x{0,X}", processId), err);
//			}
//            SetupControlHandler();
//		}

        /// <summary>
        /// Detaches the calling process from its console.
        /// </summary>
        public static void FreeConsole()
        {
            ReleaseControlHandler();
            if (!WinCon.FreeConsole())
            {
                throw new IOException("Unable to free console", Marshal.GetLastWin32Error());
            }
        }