Howto hide a console app window and don't show it in the taskbar

Discussion in 'Microsoft Dot NET Framework' started by klwizzard, Jun 9, 2008.

  1. klwizzard

    klwizzard Guest

    Hello at all,

    I want to use an console application as an host.
    In one other component I want to implement an tray Icon.
    For this case I want to hide the consoleapp window after starting dthe
    application.
    Also I don't want that console app window will shown in the taskbar.

    Here are my questions:
    1. : How can I find a sample or further information about hiding the window
    after application start?
    2. : How can I find a sample or further information about to avoid that the
    console app window will shohn in the task bar?

    Thanks for your time and your help.

    Best regards
    Detlev
     
    klwizzard, Jun 9, 2008
    #1
    1. Advertisements

  2. klwizzard

    Marc Gravell Guest

    Just don't build it as a console exe; build it as a windows exe and
    there will be no console.
    The console is an OS-level flag in the PE header; disabling it at
    runtime is tricky at best...

    Marc
     
    Marc Gravell, Jun 9, 2008
    #2
    1. Advertisements

  3. klwizzard

    klwizzard Guest

    Hello Marc,

    thanks a lot for your fast help.
    I' afraid that this will simpliest the solution for my problem.
    I will take this way for my solution.
    I'm not a experianced framework developer, what means the PE header?

    Best regards
    Detlev

    "Marc Gravell" <> schrieb im Newsbeitrag
    news:...
    > Just don't build it as a console exe; build it as a windows exe and there
    > will be no console.
    > The console is an OS-level flag in the PE header; disabling it at runtime
    > is tricky at best...
    >
    > Marc
     
    klwizzard, Jun 9, 2008
    #3
  4. klwizzard

    Marc Gravell Guest

    PE means Portable Executable; it is the file format that windows "exe"
    files use (and in fact "dll"s too).

    At the start of this file is the header, which has some flags to tell
    the OS what to do with it. One of these flags indicates whether that
    process will need a console.

    So basically - when you compile, it sets this flag depending on whether
    you have chosen your project as a windows exe or a console exe. Just
    change it to a windows exe.

    Marc
     
    Marc Gravell, Jun 9, 2008
    #4
  5. klwizzard

    klwizzard Guest

    Hello Marc,

    thanks a lot for your fast and detailed help.
    I will later more learn about PE and the using of it.

    Best regrads
    Detlev

    "Marc Gravell" <> schrieb im Newsbeitrag
    news:...
    > PE means Portable Executable; it is the file format that windows "exe"
    > files use (and in fact "dll"s too).
    >
    > At the start of this file is the header, which has some flags to tell the
    > OS what to do with it. One of these flags indicates whether that process
    > will need a console.
    >
    > So basically - when you compile, it sets this flag depending on whether
    > you have chosen your project as a windows exe or a console exe. Just
    > change it to a windows exe.
    >
    > Marc
     
    klwizzard, Jun 9, 2008
    #5
  6. klwizzard

    klwizzard Guest

    Hello Mike,

    many thanks for the snippet.
    Sorry for my late answer, I've checked this thread not for a while.

    Best regards
    Detlev

    "Michael D. Ober" <obermd.@.alum.mit.edu.nospam.> schrieb im Newsbeitrag
    news:...
    > "klwizzard" <> wrote in message
    > news:uhN$...
    >> Hello at all,
    >>
    >> I want to use an console application as an host.
    >> In one other component I want to implement an tray Icon.
    >> For this case I want to hide the consoleapp window after starting dthe
    >> application.
    >> Also I don't want that console app window will shown in the taskbar.
    >>
    >> Here are my questions:
    >> 1. : How can I find a sample or further information about hiding the
    >> window after application start?
    >> 2. : How can I find a sample or further information about to avoid that
    >> the console app window will shohn in the task bar?
    >>
    >> Thanks for your time and your help.
    >>
    >> Best regards
    >> Detlev

    >
    > Here's the code in VB
    >
    > ' Windows API to minimize the console window after initialization
    > Private Declare Function GetConsoleWindow Lib "kernel32.dll" () As IntPtr
    > Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As
    > IntPtr, ByVal nCmdShow As Int32) As Int32
    > Private Const SW_SHOWMINNOACTIVE As Int32 = 7
    > Private Const SW_SHOWNORMAL As Int32 = 1
    > Private Const SW_HIDE as Int32 = 0
    >
    > ' In the code
    > ShowWindow(GetConsoleWindow(), SW_HIDE)
    >
    > Mike.
    >
    >
     
    klwizzard, Jun 13, 2008
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J?rg Brenner

    Howto quit a console application ??

    J?rg Brenner, Aug 6, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    2
    Views:
    5,210
    Sijin Joseph
    Aug 8, 2004
  2. Randy Danielson
    Replies:
    0
    Views:
    234
    Randy Danielson
    Aug 28, 2004
  3. assaf

    How to hide and show the app's console?

    assaf, Nov 3, 2004, in forum: Microsoft Dot NET Framework
    Replies:
    0
    Views:
    236
    assaf
    Nov 3, 2004
  4. Stephen Walch

    Making a Winforms app behave like a Console app

    Stephen Walch, Jan 31, 2006, in forum: Microsoft Dot NET Framework
    Replies:
    5
    Views:
    342
    Guest
    Feb 1, 2006
  5. Barry

    Windows Forms App as Console App

    Barry, Jul 9, 2007, in forum: Microsoft Dot NET Framework
    Replies:
    3
    Views:
    251
    Barry
    Jul 10, 2007
Loading...

Share This Page