tags:

views:

170

answers:

1

I have a wpf application that needs to extract the icon off of an executable I found here that i can do this

Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);

but when I try to set the source of a wpf Image I get "Cannot implicitly convert type 'System.Drawing.Icon' to 'System.Windows.Media.ImageSource'

Any suggestions ?

+2  A: 

Icons get no love in the .NET framework. You'll have to use Icon.Save() to save the icon you got into a MemoryStream. Which allows you to use the IconBitmapDecoder constructor that takes a stream.

Hans Passant
uhmm is there any other more preferable way to extract the icon then?
irco
What's wrong with my proposed solution? Two lines of code.
Hans Passant