日期:2014-05-18  浏览次数:20825 次

隐藏开始菜单
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace 隐藏开始菜单
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  private const int SW_HIDE = 0;
  private const int SW_SHOW = 5;
  [DllImport("user32.dll")]
  public static extern int FindWindow(string lpClassName, string lpWindowName);
  [DllImport("user32.dll")]
  public static extern int FindWindowEx(int hWnd1,int hWnd2,string lpsz1,string lpsz2);
  [DllImport("user32.dll")]
  public static extern int ShowWindow(int hWnd, int nCmdShow);
  private void button1_Click(object sender, EventArgs e)
  {
  ShowWindow(FindWindowEx(FindWindow("Shell_TrayWnd", null),0, "Button", null), SW_HIDE);
  }

  private void button2_Click(object sender, EventArgs e)
  {
  ShowWindow(FindWindowEx(FindWindow("Shell_TryWnd",null),0,"Button",null),SW_HIDE);
  }
  }
}
Win7操作系统不能隐藏开始菜单,帮忙解决以下!

------解决方案--------------------
上面的Xp,
win7如下
C# code

win7中Spy++才发现开始菜单就是窗口
 class Program
    {
        // 获得窗体句柄
        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(String className, String captionName);
        [DllImport("user32.dll")]
        public static extern bool ShowWindow(IntPtr hwnd, uint nCmdShow);
        static void Main(string[] args)
        {
            // 获得任务栏句柄
            var rwl = FindWindow("Shell_TrayWnd", null);
            //当nCmdShow=0:隐藏;=1:显示
            ShowWindow(rwl, 0);
            var rwl2 = FindWindow("Button", null);
            ShowWindow(rwl2, 0);
            Console.Read();
            ShowWindow(rwl2, 1);
            ShowWindow(rwl, 1);
        }
    }