Home All Groups Group Topic Archive Search About

Get the Application Icon??

Author
3 Apr 2006 11:49 PM
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.

Author
4 Apr 2006 12:00 PM
AMercer
> 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))
Author
4 Apr 2006 3:28 PM
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())


Show quoteHide quote
"AMercer" <AMer***@discussions.microsoft.com> wrote in message
news:F991F365-6385-4CCC-AC01-11DAF78DBD60@microsoft.com...
>> 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))
>
Author
4 Apr 2006 4:17 PM
AMercer
> 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.