Get the Application Icon??

  • Thread starter Thread starter Arthur Dent
  • Start date Start date
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.
 
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))
 
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())
 
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.
 
Back
Top