Displaying folder icons in an XP TreeView control

1. Create TreeView control and ImageList; add system icons to ImageList and attach it to the TreeView. In Windows XP, these system icons are 32-bit which includes a 8-bit transparency alpha channel, so unless you can make your own icons which will look nice like that, you'll want to use the system icons, which can be viewed here.
{
   HWND hwndTV;

   hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,g_wszNull,
      WS_CHILD|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS |WS_VISIBLE,
      10,10,300,300,hWnd,(HMENU)98,g_hInst,0);

   hil = ImageList_Create(16,16,ILC_COLOR32,10,10);

   HICON hi;

   HMODULE hmod = LoadLibraryA("shell32");

   hi = LoadIcon(hmod,MAKEINTRESOURCE(4));   // closed folder
   ImageList_AddIcon(hil,hi);
   hi = LoadIcon(hmod,MAKEINTRESOURCE(5));   // open folder
   ImageList_AddIcon(hil,hi);

   TreeView_SetImageList(hwndTV,hil,TVSIL_NORMAL);

   FreeLibrary(hmod);
}
2. For Windows XP, to use the 32-bit icons, you must now mark your application manifest as ComCtl32 version 6 compilant. Name this file YourApp.exe.manifest, save it in UTF8 format (using notepad) and put it in the directory with your executable. You can also include it in the executable as resource number 1 of type RT_MANIFEST.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
   version="1.0.0.0"
   processorArchitecture="x86"
   name="foo.bar.YourApp"
   type="win32"
/>
<description>YourApp description</description>
<dependency>
   <dependentAssembly>
   <assemblyIdentity
      type="win32"
      name="Microsoft.Windows.Common-Controls"
      version="6.0.0.0"
      processorArchitecture="X86"
      publicKeyToken="6595b64144ccf1df"
      language="*"
      />
   </dependentAssembly>
</dependency>
</assembly>
3. If you want to use ImageList_DrawIndirect and the new members of IMAGELISTDRAWPARAMS to manually draw the 32-bit icons, you'll have to set _WIN32_WINNT = 0x501 before including windows.h. This causes the cbSize member to be a larger value at compile-time, indicating your app's desire to use new version 6 functionality.