永久隐藏任务栏

Code:

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace CsDev
{
    class c2
    {
        private const int SW_HIDE = 0;
        private const int SW_SHOW = 1;

        [DllImport("user32.dll")]
        private static extern int FindWindow(string className, string windowText);
        [DllImport("user32.dll")]
        private static extern int ShowWindow(int hwnd, int command);

        static void Main()
        {
            int hWnd = FindWindow("Shell_TrayWnd", "");
            //ShowWindow(hWnd, SW_SHOW);//显示任务栏
	      ShowWindow(hWnd, SW_HIDE);//隐藏
            Console.ReadKey();
        }
    }
}

一旦隐藏,即使关闭程序任务栏还是隐藏的,必须调用ShowWindow函数来显示。

你可能感兴趣的:(C#)