You can load an icon from an .ICO file using LoadImage.
Code:
HICON LoadIconFromFile( LPCTSTR fileName ) {
return (HICON)LoadImage( NULL, fileName, IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
}
You can also load an icon from an icon resource using LoadIcon.
Code:
LoadIcon( hInst, MAKEINTRESOURCE(INSTALL_ICON) );
To set your system tray icon, assign your icon handle to the hIcon member of NOTIFYICONDATA.
Code:
NOTIFYICONDATA data ;
data.hIcon = LoadIcon( hInst, MAKEINTRESOURCE(INSTALL_ICON) );
To create an icon resource, add a ICON resource statement into a .RC file:
Code:
#include "iconresource.h"
INSTALL_ICON ICON "install.ico"
INSTALL_ICON is the identifier for the icon, which is defined in iconresource.h:
Code:
#define INSTALL_ICON 103
Add the iconresource.h file into your project and compile it.