getting icon from embedded resource

F

farseer

Hi,
I created a new resouce ("app.resx") in my project and added an icon to
this resource with name "IL_ICON". I would like to use this resource
in some unmanaged code, in particular, with the api function
SHNotificationAdd. How can i do this?
i have tried using ResourceManager to get that icon, but i am getting
back NULL. Even if i did get back an icon, how can i use this to with
the hIcon parameter of SHNotificationAdd?

thank you much
 
B

Bob Powell [MVP]

When you load the icon you must know its fully qualified name within the
assembly.

This could be something like "MyDLL.SomeFolder.Icon1.ico"

To dump all your resource names add this simple code to the constructor of
some class that starts when the app is loaded or the DLL is used:

foreach(string s in this.GetType().Assembly.GetManifestResourceNames())
System.Diagnostics.Trace.WriteLine(s);

This will emit the names of all the resources embedded in your assembly and
you can see how to qualify the names.

Once you know them, you can remove the two lines of debug helper code again.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top