nusdownloader/NUS Downloader/Program.cs

70 lines
2.4 KiB
C#
Raw Normal View History

///////////////////////////////////////////
// NUS Downloader: Program.cs //
// $Rev:: $ //
// $Author:: $ //
// $Date:: $ //
///////////////////////////////////////////
using System;
2009-06-11 03:16:49 +02:00
using System.Windows.Forms;
using System.Runtime.InteropServices;
2009-06-11 03:16:49 +02:00
namespace NUS_Downloader
{
static class Program
{
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
2009-06-11 03:16:49 +02:00
/// <summary>
/// The main entry point for the application.
/// </summary>
//[STAThread]
2009-06-11 03:16:49 +02:00
static void Main(string[] args)
{
//Console.Title = "NUSD";
// hide the console window
//setConsoleWindowVisibility(false, Console.Title);
2009-06-11 03:16:49 +02:00
if (args.Length != 0)
{
// hide the console window
//setConsoleWindowVisibility(true, Console.Title);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
2009-06-11 03:16:49 +02:00
Application.Run(new Form1(args));
}
2009-06-11 03:16:49 +02:00
else
{
// hide the console window
//setConsoleWindowVisibility(false, Console.Title);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
2009-06-11 03:16:49 +02:00
Application.Run(new Form1());
}
}
public static void setConsoleWindowVisibility(bool visible, string title)
{
//Sometimes System.Windows.Forms.Application.ExecutablePath works for the caption depending on the system you are running under.
IntPtr hWnd = FindWindow(null, title);
if (hWnd != IntPtr.Zero)
{
if (!visible)
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
else
//Show window again
ShowWindow(hWnd, 1); //1 = SW_SHOWNORMA
}
2009-06-11 03:16:49 +02:00
}
}
}