用API函数:Findwindow
按类查找:Shell_TrayWnd,返回的是窗体的句柄。
只要用了窗体的句柄想做什么就做什么了!

解决方案 »

  1.   

    Sample:[DllImport("user32.dll", EntryPoint="FindWindow")]
     public static extern IntPtr FindWindow (
      string lpClassName,
      string lpWindowName
     );
    [DllImport("user32.dll", EntryPoint="ShowWindow")]
     public static extern int ShowWindow (
     IntPtr hwnd,
     int nCmdShow
     );
     [DllImport("user32.dll", EntryPoint="GetWindowRect")]
      public static extern int GetWindowRect (
       IntPtr hwnd,
       ref Rectangle lpRect
      );
     [DllImport("user32.dll", EntryPoint="IsWindowVisible")]
    public static extern bool IsWindowVisible (
    IntPtr hwnd
    );
    public const int SW_HIDE = 0;
    public const int SW_SHOW = 5;
    private void button22_Click(object sender, System.EventArgs e)
    {
    IntPtr hWnd = FindWindow("Shell_TrayWnd",null); 
    if(hWnd != IntPtr.Zero)
    {
     if(IsWindowVisible(hWnd))
                      ShowWindow(hWnd,SW_HIDE);
     else
     ShowWindow(hWnd,SW_SHOW);
      Rectangle rect = new Rectangle(0,0,0,0);
      GetWindowRect(hWnd,ref rect);
      MessageBox.Show(rect.ToString());     
    }
    }