搜了很多试了很久,获取到的总是这个图标
求个有用的获取应用程序图标的代码

解决方案 »

  1.   

    http://topic.csdn.net/u/20100728/16/d7d96617-645a-4c12-9ed9-8424a0e5b232.html
      

  2.   

    this.Icon = Icon.ExtractAssociatedIcon(@"C:\Program Files\mozilla firefox\firefox.exe");
    这个简单,直接获取了~~[align=center]*****************************
    * 本内容使用CSDN 小秘书回复 *
    每天回帖即可得10分可用分! *
    *****************************[/align]
      

  3.   

    2L,你那个试过还是获取不到,后来在百度找到篇,已经解决了,给大家看下 [System.Runtime.InteropServices.DllImport("shell32.dll")] 
            private static extern int ExtractIconEx(string lpszFile, int niconIndex, ref IntPtr phiconLarge, ref IntPtr phiconSmall, int nIcons);      public void getico(string l, PictureBox o)
            {
                if (l != "")
                {
                    IntPtr Large, Small;
                    int nIcons;
                    Large = (IntPtr)0;
                    Small = (IntPtr)0;
                    nIcons = ExtractIconEx(l, -1, ref Large, ref Small, 1);
                    ExtractIconEx(l, 0, ref Large, ref Small, 1);
                    o.Image = Icon.FromHandle(Large).ToBitmap();
                }
            }private void button1_Click(object sender, EventArgs e)
            {
                string x = @"路径";
                getico(x, pictureBox1);
            }