1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| [System.Runtime.InteropServices.DllImport("user32")]
static extern int SetWindowPos(IntPtr hwnd, int hwndInsertAfter,
int x, int y, int cx, int cy, int Flags);
static IntPtr handle;
static bool visible;
static void Main(string[] args)
{
handle = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
NotifyIcon notifyIcon = new NotifyIcon();
notifyIcon.Icon = System.Drawing.SystemIcons.Application;
notifyIcon.Visible = true;
notifyIcon.Click += new EventHandler(notifyIcon_Click);
MasquerConsole();
visible = false;
Application.Run();
}
static void notifyIcon_Click(object sender, EventArgs e)
{
if (visible) MasquerConsole();
else AfficherConsole();
visible = !visible;
}
static void AfficherConsole()
{
SetWindowPos(handle, 0, 0, 0, 0, 0, 0x43);
}
static void MasquerConsole()
{
SetWindowPos(handle, 0, 0, 0, 0, 0, 0x83);
} |
Partager