|
-
December 13th, 2005, 08:56 PM
#1
Hiding console window?
how can i hide the console window for the current app? (ie not opened thru System.Diagnostics.Process)
-
December 18th, 2005, 09:04 AM
#2
Re: Hiding console window?
There might be other/easier solutions to this, but anyway:
Code:
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace HideConsole
{
class Program
{
[DllImport("user32.dll")]
public static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
public const int SW_HIDE = 0;
public const int SW_SHOWNORMAL = 1;
public const int SW_NORMAL = 1;
public const int SW_SHOWMINIMIZED = 2;
public const int SW_SHOWMAXIMIZED = 3;
public const int SW_MAXIMIZE = 3;
public const int SW_SHOWNOACTIVATE = 4;
public const int SW_SHOW = 5;
public const int SW_MINIMIZE = 6;
public const int SW_SHOWMINNOACTIVE = 7;
public const int SW_SHOWNA = 8;
public const int SW_RESTORE = 9;
public const int SW_SHOWDEFAULT = 10;
public const int SW_FORCEMINIMIZE = 11;
public const int SW_MAX = 11;
static void Main(string[] args)
{
// get current process
Process p = Process.GetCurrentProcess();
// get main windows handle (console)
IntPtr pHandle = p.MainWindowHandle;
// hide it
if (ShowWindow(pHandle, SW_HIDE) == 0)
{
// ShowWindow failed
}
// show it
if (ShowWindow(pHandle, SW_SHOW) == 0)
{
// ShowWindow failed
}
}
}
}
- petter
-
February 13th, 2006, 06:22 PM
#3
Re: Hiding console window?
Someone else posted this solution which worked for me.
"Create a console application and set in the project properties that it's a windows application. This will make it run in background. "
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|