Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Hide Black Console Window later in program

Hide Black Console Window later in program

Scheduled Pinned Locked Moved C#
comhelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LimitedAtonement
    wrote on last edited by
    #1

    Dear Sirs, I searched online and the forums and can't find the answer to my question. I would like my program to hide its console window in a managed way, but only AFTER allowing the program to output there. Basically, it goes like this:

    public .ctor()
    {
    _Init();
    _Open_SS();
    System.Console.Hide();/*believe it or not, this doesn't work!*/
    }

    So, if anyone knows how to do this in a MANAGED-ONLY context (I don't want to use DllImport("Kernel32.dll")]extern int FreeConsole();). Thanks in advance for your help!! In Christ, Aaron Laws http://ProCure.com

    T 1 Reply Last reply
    0
    • L LimitedAtonement

      Dear Sirs, I searched online and the forums and can't find the answer to my question. I would like my program to hide its console window in a managed way, but only AFTER allowing the program to output there. Basically, it goes like this:

      public .ctor()
      {
      _Init();
      _Open_SS();
      System.Console.Hide();/*believe it or not, this doesn't work!*/
      }

      So, if anyone knows how to do this in a MANAGED-ONLY context (I don't want to use DllImport("Kernel32.dll")]extern int FreeConsole();). Thanks in advance for your help!! In Christ, Aaron Laws http://ProCure.com

      T Offline
      T Offline
      The Man from U N C L E
      wrote on last edited by
      #2

      I know you said Managed code, however I don't see any way of avoiding it as the console is an unmanaged host for the application output. However I would recommend

      [DllImport("user32.dll")]static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

      rather than FreeConsole as you don't really want to detach the process from the console, just hide the console. Well, having said that, maybe you do, but I wouldn't.

      If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk

      P 1 Reply Last reply
      0
      • T The Man from U N C L E

        I know you said Managed code, however I don't see any way of avoiding it as the console is an unmanaged host for the application output. However I would recommend

        [DllImport("user32.dll")]static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        rather than FreeConsole as you don't really want to detach the process from the console, just hide the console. Well, having said that, maybe you do, but I wouldn't.

        If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) www.JacksonSoft.co.uk

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        I use FreeConsole for applications than can be run in either console or GUI mode.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups