從 C#編寫的Exe裡面提取表徵圖和圖片

來源:互聯網
上載者:User

標籤:

記得原來是可以通過PE直接提取Exe裡面的圖片的,不知道為什麼不能用了,下面是通過載入程式集反射出Resources 裡面的圖片或者表徵圖;

提取結果直接存放到編譯目錄了,不知道向左向右,自己又回到Winform了

 

 //從Exe裡面提取表徵圖和圖片            Assembly assm = Assembly.LoadFrom("Swtpro4.exe");            HashSet<string> l_strHashType = new HashSet<string>();            foreach (string resName in assm.GetManifestResourceNames())            {                Stream stream = assm.GetManifestResourceStream(resName);                ResourceReader rr = new ResourceReader(stream);                IDictionaryEnumerator enumerator = rr.GetEnumerator();                while (enumerator.MoveNext())                {                    DictionaryEntry de = (DictionaryEntry)enumerator.Current;                    l_strHashType.Add(de.Value.GetType().ToString());                    switch (de.Value.GetType().ToString())                    {                        case "System.Drawing.Icon":                            System.Drawing.Icon ic = (Icon)de.Value;                            //路徑根據自己需要更改                            using (System.IO.Stream sm = new FileStream(de.Key.ToString() + ".ico", FileMode.Create))                            {                                ic.Save(sm);                            }                            break;                        case "System.Drawing.Bitmap":                            System.Drawing.Bitmap icbmp = (Bitmap)de.Value;                            icbmp.Save(de.Key.ToString() + ".bmp");                            break;                            //TODO 這裡我唯寫了2種                        default:                            break;                    }                    //de.Key是資源名                    //de.Value是資源內容                }            }            Console.WriteLine(l_strHashType.Count);

 

從 C#編寫的Exe裡面提取表徵圖和圖片

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.