Make Application Icon visible with Systray (Windows only)

Share your advanced PureBasic knowledge/code with the community.
Oso
Enthusiast
Enthusiast
Posts: 595
Joined: Wed Jul 20, 2022 10:09 am

Re: Make Application Icon visible with Systray (Windows only)

Post by Oso »

Axolotl wrote: Thu Dec 07, 2023 3:50 pm When I run e.g. the help examaple code for AddSysTrayIcon the system creates a new key under HKCU\Control Panel\NotifyIconSettings\
(Unfortunately) with ExecutablePath = "....\AppData\Local\Temp\PureBasic_Compilation0.exe"
Thankfully I don't have that problem, because I happen to be doing my PB development on Windows Server, but deploying the compiled routine to Windows 11 and consequently it has a proper application name.

Anyway, yes, it's working and I've got my icon appearing just nicely. The way that I've programmed this, is that when the application starts, I send the icon to the system tray as a 1-second test. While the icon is displayed, I then promote it in the registry. Since this is a background task which begins when the user logs-in, the 1-second test is useful to ensure that it is working.

Image

Incidentally, what is the relevance of the optional parameter ComputerName.s in the code?
Axolotl
Addict
Addict
Posts: 837
Joined: Wed Dec 31, 2008 3:36 pm

Re: Make Application Icon visible with Systray (Windows only)

Post by Axolotl »

ComputerName.s is the name of remote machine - omitting defaults to the current machine.
Bear in mind that only HKLM and HKU are available on remote machines.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Oso
Enthusiast
Enthusiast
Posts: 595
Joined: Wed Jul 20, 2022 10:09 am

Re: Make Application Icon visible with Systray (Windows only)

Post by Oso »

Axolotl wrote: Sat Dec 09, 2023 11:15 am ComputerName.s is the name of remote machine - omitting defaults to the current machine.
Bear in mind that only HKLM and HKU are available on remote machines.
Thanks for that Axolotl

I hadn't realised they could be accessed in such a way that referred to another machine — something I've never needed to work with to be honest. I can't help but feel that the Windows registry is something of a juggernaut. As I think you mentioned earlier in the post, if you deleted an application, it doesn't remove reference to it, as far as the icon is concerned.

I remember the Windows NT 4 days, when after installing the new O/S, it prompted the user to take an all important backup of the registry onto a 1.44MB floppy disc but on attempting to do so, finding that it didn't fit onto the disc anyway, so the whole process turned out to be pointless :lol:
Post Reply