[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

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

klwizzard

6/9/2008 2:20:00 PM

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


6 Answers

Marc Gravell

6/9/2008 2:32:00 PM

0

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

6/9/2008 2:42:00 PM

0

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" <marc.gravell@gmail.com> schrieb im Newsbeitrag
news:e5lUH2jyIHA.1436@TK2MSFTNGP05.phx.gbl...
> 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

6/9/2008 2:54:00 PM

0

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

6/9/2008 3:14:00 PM

0

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" <marc.gravell@gmail.com> schrieb im Newsbeitrag
news:OLFokCkyIHA.2340@TK2MSFTNGP04.phx.gbl...
> 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


Michael D. Ober

6/10/2008 3:15:00 AM

0

"klwizzard" <klwizzard@gmx.de> wrote in message
news:uhN$gvjyIHA.5472@TK2MSFTNGP06.phx.gbl...
> 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

6/13/2008 1:00:00 PM

0

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:F4mdnQPF698obNDVnZ2dnUVZ_oHinZ2d@earthlink.com...
> "klwizzard" <klwizzard@gmx.de> wrote in message
> news:uhN$gvjyIHA.5472@TK2MSFTNGP06.phx.gbl...
>> 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.
>
>