I programmatically change the window icon using this function:
void Change_program_icon(char* icon_path)
{
int window;
HANDLE handle_icon;
handle_icon = LoadImage(0, icon_path, IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
GetPanelAttribute (panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &window);
SendMessage((HWND)window, WM_SETICON, ICON_SMALL, (LPARAM)handle_icon);
}
and passing to it a string containing the full path of the icon ("C:\\images\\icon.ico" for example)