再谈生成缩略图的问题(200分)

  • 主题发起人 主题发起人 pscj
  • 开始时间 开始时间
P

pscj

Unregistered / Unconfirmed
GUEST, unregistred user!
以前有不少讨论,我看过收获不少,我现在想要实现的是通过Shell调用w2k/xp的图像缩略图
具体是通过com,IExtractImage这个接口可以实现,以下函数是我从ms的网站上search到的,
但是我传的参数总是报错,请大家帮忙看看
HBITMAP __fastcall TForm1::ExtractThumb(LPSHELLFOLDER psfFolder, LPCITEMIDLIST localPidl,const SIZE* prgSize, DWORD dwRecClrDepth)
{
LPEXTRACTIMAGE pIExtract = NULL;
HRESULT hr;
hr = psfFolder->GetUIObjectOf(NULL, 1, &localPidl, IID_IExtractImage,
NULL, (void**)&pIExtract);
if(NULL == pIExtract) // early shell version, thumbs not supported
return NULL;

OLECHAR wszPathBuffer[MAX_PATH];
DWORD dwPriority = 0; // IEI_PRIORITY_NORMAL is defined nowhere!
DWORD dwFlags = NULL;
HBITMAP hBmpImage = 0;
hr = pIExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority,
prgSize, dwRecClrDepth, &dwFlags);

if(NOERROR == hr) hr = pIExtract->Extract(&hBmpImage);
pIExtract->Release();

return hBmpImage; // callers should DeleteObject this handle after use
}
以下是调用部分:
LPSHELLFOLDER lpsf1=NULL;
LPITEMIDLIST lpidl=NULL;
HRESULT hs;

if(SUCCEEDED(SHGetDesktopFolder(&lpsf1)))
{
wchar_t wpath[MAX_PATH];
StringToWideChar("d://2.bmp",wpath,MAX_PATH);

unsigned long eaten;
PItemIDList NewPIDL;

hs=lpsf1->ParseDisplayName(NULL,NULL,wpath,&eaten,&NewPIDL,NULL);
if(NOERROR == hs)
{
     Graphics::TBitmap *bmp=new Graphics::TBitmap();
bmp->Handle=ExtractThumb(adv,NewPIDL,lpsize,8);
bmp->SaveToFile("d://1.bmp");
}
}
问题出在调用GetUIObjectOf函数上,总是返回失败值
 
后退
顶部