Wednesday 15 February 2012

c# - Embed multiple icons in WPF EXE -


I have a WPF assembly in which I would like to embed five icons for different file types associated with my application. How can I embed these exchanges in my EXE?

@smoore @Groky @ChrisF, thanks. Unfortunately, this is not what I asked. I think my question was quite unclear 0_ ° Please repeat this question to me:


I have an icon, such as Application.ico , document.ico , etc projects in my WPF as a resource. I use these icons in most cases with the following cases:

  & lt; Image Source = "/ MyAssembly; Component / Resource / Icon / application.ico" />  

This works all the time I know.


What is my question, how can I use the same icon from Windows Explorer for file associations in the registry? I want to be able to use the icon with a path like this:

  c: \ program files \ MyApp \ MyApp.exe, 1  
< P> How the mouse is connected to the file type in HKEY_CLASSES_ROOT

AFAIK, I should use a resource file ( .rc ), compile it and import it to your EXE Some with lines:

  101 RT_ICON Application.ico 102 RT_ICON Document.ico // etc ...  

Is this the correct way in WPF? Is there any alternative, especially since this method gives birth to the extinction of the assembly from my assemblyInfo.cs I'm still ready to write version information in the resource instead of assembly information .

I got a solution ! This is not right, but this is what I want! As I used very long Scandinavian nights to find a solution, I think I have to share it here.

Here I have done that:

1) Writes a dumb console to the C # app

  class ResTest {static void main () {System .Console.WriteLine ("Hello World!"); }}  

2) A simple csc restest.cs to test my code.

3) Notepad opened and I wrote a app in a file. RC was dubbed. "icon" V. App.rc , the.

5) Reuters csc but this time:

  csc is a new file,  app. /win32res:App.res restest.cs  

6) restest.exe now had an icon with 101 ID and I could get two other icons in Xialis Iconworkshop


Now, I found that my assembly information (version, product name, blah blah blah ) disappeared. I googled VS_VERSION_INFO and came to the MSDN article about the VERSIONINFO structure which defines the characteristics I need in RC files.

I would prefer more 'automated' method, but I want to use C # Express and Windows Vista SDK.

- Hope you can use it ...


No comments:

Post a Comment