Results 1 to 4 of 4

Thread: VB NET Get path of an icon displayed on systray and which can change for same program

  1. #1

    Thread Starter
    Registered User
    Join Date
    Dec 2017
    Posts
    2

    VB NET Get path of an icon displayed on systray and which can change for same program

    Hi,

    You can develop programs which appears into the taskbar systray with several icons depending several states. The same icon that is on systray appears on the Task Manager.

    I would like the Visual Basic .NET code to get the path of the icon that is displayed into the taskbar systray (also called notification area).

    I have already tried to get the handle of the process and use the function “Icon.ExtractAssociatedIcon” but it always returns the DEFAULT program icon but not the DISPLAYED icon.

    Could you help me giving me a code which could permit to get the path of the DISPLAYED icon ?

    Thank you for your help.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: VB NET Get path of an icon displayed on systray and which can change for same pro

    Welcome to VBForums

    The icon does not need to exist as a file (or resource), it can be generated at run time.

    I have done that for a few applications, and the icon is just stored in memory. For the icon shown by Task Manager (basically a percentage bar-graph) it would make much more sense for the icon to be generated at run-time rather than having 101 icon files/resources (which would take quite a lot of space).

    As such Icon.ExtractAssociatedIcon is not the way to go, because it gets the icon from a file (or resource).


    I don't know how to get the "live" icon, but depending on what you are actually trying to achieve then getting the icon may not be the best way (eg: if you are trying to get the icon from Task Manager so you can use that to find processor usage, there are much easier ways to detect processor usage).

  3. #3

    Thread Starter
    Registered User
    Join Date
    Dec 2017
    Posts
    2

    Re: VB NET Get path of an icon displayed on systray and which can change for same pro

    Thank you for your answer. I would like to precise my first post.

    the aim is to check connection status send by a program (it display his normal icon when not connected, green icon when connected, and other icon when connection is going to be established)

    The icon is integrated on the EXE or a DLL file. So get icon name on the EXE or DLL file could be the solution but I don't know :
    - where is the icon (in which EXE or DLL)
    - how to get icon name
    - how to check if the icon name on systray or task manager is the same.

    The other way to face my problem is that the program sends message notification on Windows 10notification center (ex: they appear when you connect an USB key. To access to these messages, the link is on the right of the taskbar, on the right of the hour). This could also be another way but I don’t know the code which could permit me to get the list of the messages with details (time, hour, type of message, etc).

    Thank you.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: VB NET Get path of an icon displayed on systray and which can change for same pro

    You can't find out the name of the icon in the systray, you would need to 'copy' it and load the one in the exe/dll, then compare the images pixel by pixel. If you don't already know the icon to compare it to then that is even more work, and it is also unreliable (eg: if the program is ever updated, the icons may change name and/or location).

    Reading a message from notification center is likely to be much easier, but is still a bit unreliable (it is also prone to changes from program updates).

    The best option is likely to be either getting the information directly from the program (if it provides some kind of API), or testing the connection (how depends on what kind of connection it is), or maybe even reading from and kind of logging it does (it may log to a file, or the Event Log).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width