Get the Application Icon??

A

Arthur Dent

Hello all,

I am trying to write a simple app with no forms, but which uses a system
tray icon and a context menu. I want to set the icon for the NotifyIcon to
the icon which is set for the application in the My Project settings dialog.

How can i get this icon?

Thanks in advance.
- Arthur Dent.
 
G

Guest

I am trying to write a simple app with no forms, but which uses a system
tray icon and a context menu. I want to set the icon for the NotifyIcon to
the icon which is set for the application in the My Project settings dialog.

Assuming the name of the icon is xxx, try this

Dim s as string = Application.ProductName & ".xxx.ico"
Icon = New
Icon(Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(s))
 
A

Arthur Dent

Actually, i found i think an easier way, though maybe not the "proper" way?

I wound up doing

myNotifyIcon.Icon =
System.Drawing.Icon.ExtractAssociatedIcon(Application.GetExecutablePath())
 
G

Guest

Actually, i found i think an easier way, though maybe not the "proper" way?

In my case, I have a few icons as embedded resources in my exe file, and I
can get at any one by name with the fragment in my previous post. In your
case, you want the icon associated with the app, so I think you are doing
exactly the right thing. Also, your code will work in any app without the
code needing to know the icon name, and that is a plus in my opinion.
 

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