c#使用windows api隐藏任务栏

参考

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsApplication2
{
    
    
    
    

    public partial class Form1 : Form
    {
    
    
        [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)]

static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
        IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
       [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
        
        static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);
        public Form1()
        {
    
    
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
    
    
           //  [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)];
//static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);//然后dao就版可以用权了。
           
       // IntPtr a = new IntPtr(10);
//IntPtr b = new IntPtr(a.ToInt64()+10);

           

if (trayHwnd != IntPtr.Zero)
{
    
    
    ShowWindow(trayHwnd, 1);
}
        
        }
    }
}

猜你喜欢

转载自blog.csdn.net/weixin_40938312/article/details/109158260