需要调用api完成
声明:
VB.NET版本
Private   Declare   Auto   Function   SHGetFileInfo   _  
          Lib   "shell32"   (ByVal   pszPath   As   String,   ByVal   dwFileAttributes   As   Integer,   ByRef   psfi   As   SHFILEINFO,   _  
          ByVal   cbFileInfo   As   Integer,   ByVal   uFlags   As   Integer)   As   Integer
C#中建立了一个类(原方法来自网友)
GetAppIconApi

 1获得应用程序的图标(c#描述)using System;
 2获得应用程序的图标(c#描述)using System.Reflection;
 3获得应用程序的图标(c#描述)using System.Runtime.InteropServices;
 4获得应用程序的图标(c#描述)namespace GetAppIcon
 5
调用API函数,并生成ico文件
 1获得应用程序的图标(c#描述)private void button1_Click(object sender, System.EventArgs e)
 2        }
加入生成的ICO文件不能直接作为窗体的ICO,会报错"参数Picture必须是可用作ICO的图片,我研究过,问题应该是    
 oBp=this.Icon.ToBitmap();
      oBp.Save(strNewFile,System.Drawing.Imaging.ImageFormat.Icon);
在保存时应该根据ico文件的格式进行设置,后来一直没有成功
如果想将其他窗体的图标换成刚才生成的图标,可以如下方法
 1获得应用程序的图标(c#描述)
 2获得应用程序的图标(c#描述)            Image oImage;
 3获得应用程序的图标(c#描述)            System.Drawing.Bitmap bp;
 4获得应用程序的图标(c#描述)            bp=new Bitmap(@"c:\ff.ico");
 5获得应用程序的图标(c#描述)            try
 6            }
这是窗体中的ico图标改变

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-12-22
  • 2021-07-21
  • 2022-12-23
  • 2021-06-02
猜你喜欢
  • 2022-02-22
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-22
相关资源
相似解决方案