添加多个图标(Win32的资源),以.NET的应用 [英] Adding multiple Icons (Win32-Resource) to .NET-Application
问题描述
就可以设置应用程序图标的项目属性。如果你这样做的exe文件都会有这个图标,而不是默认的。这个图标是一个Win32资源,也可以像这样访问:
it is possible to set the Application-Icon in the Project Properties. If you do this the exe will have this icon instead of the default one. this icon is a win32-resource and can also be accessed like this:
我想有特殊的图标将使用该我的程序文件类型。一个文件类型图标关联,我可以(在的DefaultIcon钥匙MYPROG.EXE,1)在注册表中指定。
i want to have special icons for filetypes which are used by my program. to associate an filetype-icon i can specify it in the registry ("MyProg.exe,1" in the "DefaultIcon" Key).
所以如何增加更多的图标以大会,我可以用它进行文件类型关联?
so how to ADD MORE icons to the assembly that i can use it for the filetype-association?
非常感谢你。
PS:这是一个WPF的应用程序(.NET 4.0)
ps: it is a WPF-Application (.NET 4.0)
推荐答案
Windows不知道管理资源什么,你需要添加的非托管的资源,你的可执行文件。在parapura的截图,你需要选择资源文件
单选按钮。这需要一个.RES的文件,这是通过运行一个rc文件在Windows SDK RC.EXE工具创建一个二进制文件。 rc文件是包含资源的语句,一个简单的文本文件与此类似:
Windows doesn't know anything about managed resources, you need to add unmanaged resources to your executable. In parapura's screenshot, you need to select the Resource file
radio button. That requires a .res file, a binary file that's created by running the Windows SDK rc.exe tool on a .rc file. The .rc file is a simple text file that contains resource statements, similar to this:
1 ICON "mainicon.ico"
2 ICON "alternative1.ico"
3 ICON "alternative2.ico"
1 24 "app.manifest"
请务必将此文件保存到项目文件夹,而不UTF-8编码,使用记事本是最好的。创建所需的app.manifest文件与项目+添加新项,应用程序清单文件。添加该rc文件与项目+项目中添加现有项。双击它,并验证您可以看到图标和清单。用鼠标右键单击顶部节点,添加资源,然后单击版本+新。编辑的版本信息,谨防其将不再自动匹配AssemblyInfo.cs中的属性
Be sure to save this file into your project folder without utf-8 encoding, using Notepad is best. Create the required app.manifest file with Project + Add New Item, Application Manifest File. Add this .rc file to your project with Project + Add Existing Item. Double-click it and verify that you can see the icons and the manifest. Right-click the top node, Add Resource and click Version + New. Edit the version info, beware that it will no longer automatically match the attributes in AssemblyInfo.cs
您可以编译rc文件到一个.RES与Visual Studio命令提示文件:
You can compile the .rc file into a .res file with the Visual Studio Command prompt:
rc /r something.rc
其产生的.res文件,你可以在项目属性选项卡使用。这样做是pre-build事件是可取但有点难以得到的权利。方式的数量这可能出问题很多,祝你好运。
Which produces the .res file you can use in the project property tab. Doing this is a pre-build event is advisable but a bit hard to get right. The number of ways this can go wrong are numerous, good luck.
这篇关于添加多个图标(Win32的资源),以.NET的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!