如果在explore里选择缩略图的显示方式,会生成thumb.db文件,如何取得其中的缩略图?试过IExtractImage,用GetUIObject的时候总是失败。

解决方案 »

  1.   

    有SPY++看看 然后得到缩略图的hWnd不知道行否
      

  2.   

    Using thumbnail images in a list control
    http://www.codeproject.com/listctrl/thumbnail.asp
      

  3.   

    http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20822626.html
      

  4.   

    3Q各位,查了很多,我觉得IExtractImage是唯一的方法,可是在程序里就是不成功.想知道有没有人用过IExtractImage.
      

  5.   

    The IExtractImage interface is used to request a thumbnail image from a Shell folder.IExtractImage MembersExtract Used to request an image from an object, such as an item in a Shell folder. 
    GetLocation Used to request the path description of an image and specify how the image should be rendered. ResThere are two steps to the process. First, use GetLocation to request the path description of an image and specify how the image should be rendered. Then, call Extract to extract the image.If the object is free-threaded it must also expose an IRunnableTask interface, so it can be stopped and started as needed. This feature can be particularly useful when extraction may be slow.Implement IExtractImage if your namespace extension needs to provide thumbnail images to be displayed in a Shellview. Use IExtractImage if you are implementing a view of namespace objects, and want to display thumbnail images. You can use a Shell folder's IShellFolder::GetUIObjectOf method to bind to its IExtractImage interface.Interface InformationMinimum DLL Version shell32.dll version 4.70 or later 
    Custom Implementation No 
    Inherits from IUnknown 
    Header shobjidl.h 
    Minimum operating systems Windows 2000, Millennium 
    你出什么错,帮你看看,是不是OS的版本不对
      

  6.   

    这段代码是可以了,不知道你是不是在NTFS下?
    http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B298608
    You Can View an NTFS Encrypted File in Thumbnail ViewHRESULT CFileThumbExtract::CreateThumbnail(DWORD dwWidth, DWORD dwHeight, HBITMAP* pThumbnail)
    {
       LPITEMIDLIST pidlItems = NULL, pidlURL = NULL, pidlWorkDir = NULL;
       HRESULT hr;
       WCHAR pszPath[MAX_PATH];
       DWORD dwPriority = 0, dwFlags = IEIFLAG_ASPECT;
       SIZE size = { dwWidth, dwHeight };
       IExtractImage* peiURL = NULL;
       IShellFolder* psfDesktop = NULL;
       IShellFolder* psfWorkDir = NULL;  basic_string<WCHAR> wsDir,wsFile,wsTempFile;   hr = SHGetDesktopFolder(&psfDesktop);
       if(FAILED(hr)) goto OnExit;   // create shortcut if URL
     if(PathIsURLW(m_wsPath.c_str())) {
    wsTempFile = m_wsTempPath; wsTempFile += TEMP_URL;
    if(!CreateURLShortcut(m_wsPath.c_str(), wsTempFile.c_str())) goto OnExit;
    wsDir = m_wsTempPath;
    wsFile = TEMP_URL;
     }
     else {
    wsDir = m_wsDir;
    wsFile = m_wsFile;
     }
       // get working directory
     wcscpy(m_wsBuffer,wsDir.c_str());
       hr = psfDesktop->ParseDisplayName(NULL, NULL, m_wsBuffer, NULL, &pidlWorkDir, NULL);
       if(FAILED(hr)) goto OnExit;
       hr = psfDesktop->BindToObject(pidlWorkDir, NULL, IID_IShellFolder, (LPVOID*)&psfWorkDir);
       if(FAILED(hr)) goto OnExit;
       psfDesktop->Release();
       psfDesktop = NULL;
       m_pMalloc->Free(pidlWorkDir);
       pidlWorkDir = NULL;   // retrieve link information
     wcscpy(m_wsBuffer,wsFile.c_str());
       hr = psfWorkDir->ParseDisplayName(NULL, NULL, m_wsBuffer, NULL, &pidlURL, NULL);
       if(FAILED(hr)) goto OnExit;
       
       // query IExtractImage
       hr = psfWorkDir->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&pidlURL, IID_IExtractImage, NULL, (LPVOID*)&peiURL);
       if(FAILED(hr)) goto OnExit;
       
       // define thumbnail properties
       hr = peiURL->GetLocation(pszPath, MAX_PATH, &dwPriority, &size, 16, &dwFlags);
       if(FAILED(hr)) goto OnExit;
       
       // generate thumbnail
       hr = peiURL->Extract(pThumbnail);
       if(FAILED(hr)) goto OnExit;   // clean-up IExtractImage
       peiURL->Release();
       peiURL = NULL;OnExit:   // free allocated structures
       if(peiURL != NULL) peiURL->Release();
       if(pidlURL != NULL) m_pMalloc->Free(pidlURL);
       if(pidlWorkDir != NULL) m_pMalloc->Free(pidlWorkDir);
       if(psfDesktop != NULL) psfDesktop->Release();
       if(psfWorkDir != NULL) psfWorkDir->Release();
       return hr;
    }
      

  7.   

    终于好了,我原来一直用desktop folder去GetUIObjectOf,没有转到相应的目录,多谢vcmute(横秋)的代码.其他的gg,也谢谢你们:)
      

  8.   

    终于好了,我原来一直用desktop folder去GetUIObjectOf,没有转到相应的目录,多谢vcmute(横秋)的代码.其他的gg,也谢谢你们:)