从内存中的可执行文件中提取图标

发布于 2024-08-18 09:57:39 字数 139 浏览 3 评论 0原文

有谁知道一个 API 函数可以从 RAM 中的可执行文件中提取图标资源(例如,在 MemoryStream 中)?

到目前为止,我见过的所有图标提取功能都依赖于磁盘上存在的可执行文件。我想提取图标,而不必将 exe 写入临时文件,然后从中加载资源。

Does anyone know an API function to extract an icon resource from an executable file that'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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱要勇敢去追 2024-08-25 09:57:39

这从来都不是一个真正的问题。 Windows 的硬性要求是可执行文件是磁盘上的文件。否则您无法启动进程。由于无论如何您都必须将文件写入磁盘,因此使用需要文件路径的 API 从文件中提取资源永远不会出现问题。

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.

猥琐帝 2024-08-25 09:57:39

如果我们正在讨论从已构建的 DLL 中获取图标,请使用 Reflector

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

打开 DLL,只需用鼠标右键单击图标,然后单击“另存为”
这也可以通过使用反射的代码来完成

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 );

最好的问候,
约丹

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文