Change the icon on win32 window


How to change the icon of the window in win32 mode?

the icon of .exe application


@style - this is really off topic since it is a win32 question and not a Cocos2d-x question.

If you are using Resources, Explorer takes the first icon in your executable. That will be the one with the lowest id. Try managing your resources so that IDI_ICON2 is defined to be a lower integer than IDI_ICON1.

If you are not using Resources:

HANDLE hIcon = LoadImage(0, _T("imagepath/image.ico"), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
if (hIcon) {
    //Change both icons to the same icon handle.
    SendMessage(hwnd, WM_SETICON, ICON_SMALL, hIcon);
    SendMessage(hwnd, WM_SETICON, ICON_BIG, hIcon);

    //This will ensure that the application icon gets changed too.
    SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_SMALL, hIcon);
    SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_BIG, hIcon);


thank you very much ! I am trying …
ah,and I am green hand.


I’ve tried this, but I must doing something wrong. In the game.rc file that was generated, there’s this line
GLFW_ICON ICON “res\game.ico”

I’ve tried copying over the game.ico file, I’ve tried replacing this line with the name of another file, I’ve even tried copy paste to put my own images into the existing icon file, and I still cannot replace the cocos2dx icon with mine.



Hi. I’ve solve this problem in a very strange way.

I had rename .exe file and its icon auto-set up’s to my icon.