C # Open the taskbar program window
In this example, use C # To open a window displayed on the Windows taskbar.
Lab environment:
Windows XP + VS2005 +. Net 2.0 + Winform test program.
Note: You need to establish a Winform program for testing.
Code: (reprinted please indicate the source of http://blog.csdn.net/studentsky)
Public partial class Form1: Form {private const int SW_HIDE = 0; private const int SW_NORMAL = 1; private const int SW_MAXIMIZE = 3; private const int SW_SHOWNOACTIVATE = 4; private const int SW_SHOW = 5; private const int SW_MINIMIZE = 6; private const int SW_RESTORE = 9; private const int SW_SHOWDEFAULT = 10; [System. runtime. interopServices. dllImport ("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)] static extern bool ShowWindow (IntPtr hWnd, uint nCmdShow );////// Search for a form based on the window title ////////////
[System. runtime. interopServices. dllImport ("user32.dll", EntryPoint = "FindWindow")] private static extern IntPtr FindWindow (string lpClassName, string lpWindowName); public Form1 () {InitializeComponent ();} private void button#click (object sender, EventArgs e) {IntPtr hWnd = FindWindow (null, "untitled-Notepad"); ShowWindow (hWnd, SW_MAXIMIZE );}}