如何执行“shell”操作Visual Studio 2010 中嵌入图标?
据我所知,有(至少?)三种类型的图标嵌入。有 shell32.dll 和朋友使用的原始样式、.NET 的嵌入以及 WPF 使用的新类型。我正在寻找如何执行第一个图标,因为我希望有一些其他图标可用作跳转列表的资源,而跳转列表只能接受该样式。但是,我不知道如何嵌入这种风格,只有其他两种。
我该怎么做?我在 google 等上找到的所有结果都是为了将图标添加到 ResX 文件或类似文件。
As far as I can tell, there have been (at least?) three types of icon embedding. There's the original style used by shell32.dll and friends, .NET's embedding, and the new type that WPF uses. I'm looking for how to perform the first one, as I want to have a few other icons available as resources for a jumplist, which can only accept that style. However, I can't figure out how to embed in this style, only the other two.
How do I do this? All the results I find on google, etc are for adding icons to ResX files or similar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前从未听说过“图标嵌入”这个词。如果您谈论的是资源管理器中的 EXE 或 DLL 或桌面快捷方式可见的图标:这对于任何 Windows 程序都是相同的。 WF 和 WPF 都使用 /win32res 编译选项为程序集提供带有所选图标的非托管资源。您可以在 Visual Studio 中使用“文件”+“打开”+“文件”来查看它,选择 EXE 或 DLL。
要创建 .res 文件,请首先创建 .rc 文件。您可以使用 C++ IDE 创建一个。右键单击解决方案,添加新项目、Visual C++、Win32、Win32 控制台应用程序。右键单击“资源文件”文件夹,选择“添加 + 资源”,选择“图标”、“导入”。选择您的文件。根据需要重复。构建后,您将在项目的 Debug 构建目录中获得一个 .res 文件。
返回到您的 C# 项目,“项目 + 属性”、“应用程序”选项卡。选择“资源文件”选项并导航到 .res 文件。
I never heard the term "icon embedding" before. If you are talking about the icon that's visible for a EXE or DLL in Explorer or a desktop shortcut: that's done the same way for any Windows program. Both WF and WPF give the assembly an unmanaged resource with the selected icon using the /win32res compile option. You can see it in Visual Studio with File + Open + File, select the EXE or DLL.
To create a .res file, first create a .rc file. You can create one with the C++ IDE. Right-click the solution, Add New Project, Visual C++, Win32, Win32 Console Application. Right-click the Resource Files folder, Add + Resource, select Icon, Import. select your file. Repeat as needed. After you build, you'll get a .res file in the project's Debug build directory.
Back to your C# project, Project + Properties, Application tab. Select the Resource File option and navigate to the .res file.
我强烈建议您查看此处发布的此解决方案(http ://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/)。它直接集成到 ms build 生成后事件中,并且不需要非托管项目(从 .rc/.res 文件创建程序集)。
这消除了在您想要更新图标时管理第二个解决方案/程序集的依赖,并使您免于 IL 合并已编译的 c++ 程序集。
我还建议您查看 WIX 进行部署。我写了一个指南,附有这个答案,位于 这里。
I'd highly recommend taking a look at this solution posted here (http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/). It integrates right into a ms build post build event and doesn't require an unmanaged project (to create an assembly from a .rc/.res file).
This removes a dependency on managing a second solution / assembly anytime you want update an icon and saves you from IL Merging the compiled c++ assembly.
I'd also recommend taking a look at WIX for your deployment. I've written a guide that accompanies this answer located here.