Extract a program's own icon?

Just starting out? Need help? Post your questions and find answers here.
User avatar
kenmo
Addict
Addict
Posts: 2047
Joined: Tue Dec 23, 2003 3:54 am

Extract a program's own icon?

Post by kenmo »

I'm sure this has been asked and answered before, but due to vague keywords I'm having trouble searching for it.

If I compile an exe with a main icon (to appear in window's titlebar, as its explorer icon, etc) how can I extract this at runtime to also use as a tray icon?

It seems redundant to have an internal copy of the icon compiled inside, plus an external file just to be loaded for the system tray.

Suggestions?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Code: Select all

Icon = LoadIcon_(GetModuleHandle_(0), 1)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
kenmo
Addict
Addict
Posts: 2047
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Haven't tested yet, but thanks for the quick response ts-soft! Even easier than I assumed it was.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

ts-soft wrote:

Code: Select all

Icon = LoadIcon_(GetModuleHandle_(0), 1)
Thanks - works well for me in combination with DrawIcon_().
Windows 7 & PureBasic 4.4
Post Reply