我尝试用IPersistFile先打开文件,然后使用IExtractImage。可是不知道为什么用 IPersistFile::load总是返回E_FAIL,不知道是什么地方出了错。
程序如下:
HBITMAP HistoryTree_Dlg::ExtractThumb(LPCSTR m_strCurPartPath, SIZE prgSize, DWORD dwRecClrDepth)
{
HRESULT hr = NULL;
WCHAR wsz[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, m_strCurPartPath, -1, wsz, MAX_PATH);
IShellLink* pISL;
IPersistFile* pIPF;
LPEXTRACTIMAGE pExtractImage = NULL;
::CoInitialize(NULL);
hr = CoCreateInstance ( CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(void**) [$pISL )]
if ( SUCCEEDED ( hr ) )
hr = pISL->QueryInterface ( IID_IPersistFile, (void **) [$pIPF )]
if ( SUCCEEDED ( hr ) )
hr = pIPF->Load( wsz, STGM_READ);
if ( SUCCEEDED ( hr ) )
hr = pIPF->QueryInterface(IID_IExtractImage, (void ** )[$pExtractImage)]
......
}
请高手点明,小弟不行了,谢谢 |