title: How to explicitly set taskbar icon?
body: <p>In Visual Studio I generated a plain old Win32 application and stripped all the resources and generated code so that my application consists of this:</p>
  
  <pre><code>#include "stdafx.h"
  #include "IcoTest.h"
  
  int APIENTRY _tWinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
  {
      ::MessageBox( NULL, L"Testing", L"Test", MB_OK );
  }
  </code></pre>
  
  <p>When I run the application, this is what I see:</p>
  
  <p><a href="https://i.stack.imgur.com/phmpN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/phmpN.png" alt="screenshot"></a>
  </p>
  
  <p>So the question is can I change that default application icon in the taskbar? If so, what code needs to be added to do it?</p>
  
  <p>Edit:</p>
  
  <p>Here's what I did, and this kind of works but it isn't ideal.  The new icon shows up alright, but the taskbar preview window in Vista doesn't work and the system menu doesn't work so I'm just going to leave it alone for now.</p>
  
  <pre><code>HWND CreateDummyWindow(HINSTANCE hInstance, int iconId, LPCTSTR taskbarTitle)
  {
  WNDCLASSEX wcex;
  wcex.cbSize = sizeof(WNDCLASSEX);
  wcex.style          = CS_HREDRAW | CS_VREDRAW;
  wcex.lpfnWndProc    = DefWindowProc;
  wcex.cbClsExtra     = 0;
  wcex.cbWndExtra     = 0;
  wcex.hInstance      = hInstance;
  wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(iconId));
  wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
  wcex.hbrBackground  = 0;
  wcex.lpszMenuName   = 0;
  wcex.lpszClassName  = taskbarTitle,
  wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(iconId));
  ATOM atom = RegisterClassEx(&amp;wcex);
  HWND wnd = ::CreateWindow( 
      wcex.lpszClassName, taskbarTitle, WS_ICONIC | WS_DISABLED,
    -1000, -1000, 1, 1, NULL, NULL, hInstance, NULL);
  return wnd;
  }
  
  int APIENTRY _tWinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPTSTR    lpCmdLine,
                   int       nCmdShow)
  {
      HWND wnd = CreateDummyWindow(hInstance, IDI_ICON1, _T("Test") );
      ::MessageBox( wnd, _T("Testing"), _T("Test"), MB_OK );
      ::DestroyWindow( wnd );
  }
  </code></pre>