开发者

Extract icon from executable that's in memory

Does anyone know an API function to extract an icon resource from an executable file tha开发者_如何学JAVAt's in RAM (inside, say, a MemoryStream)?

All of the icon-extracting functions I've seen so far depend on the executable file being present on disk. I'd like to extract the icon without having to write the exe to a temp file, and then loading the resources from it.


This is never a real problem. Windows has the hard requirement that an executable is a file on disk. You can't start a process otherwise. Since you have to write the file to disk anyway, you never have a problem extracting resources from it with an API that requires a path to a file.


if we are talking about taking icon from already build DLL use Reflector

http://www.red-gate.com/products/reflector/

to open the DLL and the just click on the icon with the right mouse button and click Save As also this can be done by code using reflection

Assembly myAssembly = Assembly.Load("SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3");
Stream myStream = myAssembly.GetManifestResourceStream( "MyNamespace.SubFolder.MyImage.bmp" );
Bitmap bmp = new Bitmap( myStream );

Best Regards, Iordan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜