IShellItem::BindToHandler fails for too many file types

Sebastian 41 Reputation points


I'm trying to extract a thumbnail from the given file below.


For this I use SHCreateItemFromParsingName and IShellItem::BindToHandler. For several file types this works fine, but for various other file types BindToHandler only returns E_NOTIMPL Not implemented. and I am not sure why.

Normally thumbnails can be registered through thumbnail providers. Is there another method I am not aware of? This would explain why the example above fails. I stripped down the code to the absolut minimum:

   #include <windows.h>  
   #include <shlobj.h>  
   #include <thumbcache.h>  
   #include <iostream>  
   #include <shellapi.h>  
   #pragma comment(lib, "SHELL32.LIB")  
   #pragma comment(lib, "Comctl32.lib")  
   int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) {  
     if (!SUCCEEDED(hr))  
       return -1;  
   IShellItem* psi = nullptr;  
     hr = SHCreateItemFromParsingName(argv[1], NULL, IID_PPV_ARGS(&psi));  
     if (SUCCEEDED(hr)) {  
       IThumbnailProvider* pThumbProvider;  
       hr = psi->BindToHandler(NULL, BHID_ThumbnailHandler, IID_PPV_ARGS(&pThumbProvider));  
       if (SUCCEEDED(hr)) {  
         std::wcout << L"this line never succeeds";  
     return 0;  

Could anyone help out and explain what might go wrong here?

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,411 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,446 Reputation points

    This test works for me with a .clip file =>

        PIDLIST_ABSOLUTE pidl;  
        HRESULT hr = SHParseDisplayName(L"C:\\Users\\Christian\\Documents\\illustration.clip", NULL, &pidl, 0, NULL);
        IShellItemImageFactory* pShellItemImageFactory;
        hr = SHCreateItemFromIDList(pidl, IID_PPV_ARGS(&pShellItemImageFactory));
        HBITMAP hBitmap;
        SIZE size; = 320; = 200;
        hr = pShellItemImageFactory->GetImage(size, SIIGBF_RESIZETOFIT | SIIGBF_THUMBNAILONLY, &hBitmap);
        // Test display on screen
        HDC hDC = GetDC(NULL);
        HDC hDCMem = CreateCompatibleDC(hDC);
        HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDCMem, hBitmap);
        BitBlt(hDC, 0, 0,,, hDCMem, 0, 0, SRCCOPY);
        SelectObject(hDCMem, hBitmapOld);
        ReleaseDC(NULL, hDC);
    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 11,256 Reputation points Microsoft Vendor

    You can refer to this Extract thumbnail for any file in Windows question which provides a solution that extracts a thumbnail.

    0 comments No comments

  2. Sebastian 41 Reputation points

    Thanks for sharing! I will try this, but isn't there a C++ solution for this?

    0 comments No comments