有没有办法能够将所有窗体的标题栏图标一起修改了 
一个一个的修改太麻烦了

解决方案 »

  1.   

    this.ICON=new Icon("文件");
    遍历所有窗体public delegate bool EnumWindowsProc(IntPtr p_Handle, int p_Param);
      [DllImport("user32.dll")]
      public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);
      [DllImport("User32.dll", CharSet = CharSet.Auto)]
      public static extern int GetWindowText(IntPtr hWnd, out STRINGBUFFER text, int nMaxCount);   
      [DllImport("user32.dll")]
      public static extern bool IsWindowVisible(IntPtr hWnd);
      [DllImport("user32.dll")]
      public static extern IntPtr GetWindowThreadProcessId(IntPtr hwnd, ref int lpdwProcessId);
      [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
      public struct STRINGBUFFER
      {
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
      public string szText;
      }  private void button1_Click(object sender, EventArgs e)
      {
      MessageWindwos();
      }  public void MessageWindwos()
      {     EnumWindowsProc _EunmWindows = new EnumWindowsProc(NetEnumWindows);
      EnumWindows(_EunmWindows, 0);   
      }
        
      private bool NetEnumWindows(IntPtr p_Handle, int p_Param)
      {
      if (!IsWindowVisible(p_Handle))return true;  STRINGBUFFER _TitleString = new STRINGBUFFER();
      GetWindowText(p_Handle, out _TitleString, 256);  MessageBox.Show(_TitleString.szText); ///获取的窗体
        
      return true;
      }
      

  2.   

            private void Form1_Load(object sender, EventArgs e)
            {
                this.Icon = new Icon("d:\\1.ico");
            }运行时在打开窗体时自动更换图标
      

  3.   

    不好做个基类Form么。修改基类Form的icon就全都改了。