title: HICON to CImage
body: <p>I want to load the icon of an .exe in a <strong>CImage</strong> object, in order to easily display and save it in a database. My problem is that I have an <strong>HICON</strong> and I seem to only be able to load/attach an <strong>HBITMAP</strong> to a <strong>CImage</strong> object.</p>
  
  <pre><code>SHFILEINFO sfi;
  Cimage icon; 
  
  DWORD ret = SHGetFileInfo(path, 0, &amp;sfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON | SHGFI_DISPLAYNAME);
  if(ret != 0) {
      // copy info
      hIcon = sfi.hIcon;
      if(hIcon != lastHIcon &amp;&amp; hIcon != 0) {
          // This does not work, needs a HBITMAP instead of a HICON
          icon.Attach(hIcon);
      }
  }
  </code></pre>
  
  <p>Is there any easy method of doing this, or do I need to render the HICON to a DC first? It just seems to me that there should be a solution that does not require me to be a GDI expert.</p>