|
|
|
date: Mon, 7 Jul 2008 00:09:01 -0700,
group: microsoft.public.platformsdk.shell
back
problem with reading Thumbs.db in windows shell
Dear,
I am tring to read thumbs.db file format and I hear that windows shell can
read such format. So I try to write the following code but some problem faces
me:
*******************************
STDMETHODIMP CFileThumbExtract::ExtractThumbnail(HBITMAP *phBitmap)
{
LPITEMIDLIST localPidl;
//const SIZE* prgSize;
typedef IExtractImage * LPEXTRACTIMAGE;
OLECHAR wszPathBuffer[MAX_PATH];
DWORD dwPriority = 0; // IEI_PRIORITY_NORMAL is defined nowhere!
DWORD dwFlags = IEIFLAG_SCREEN;
HBITMAP hBmpImage = NULL;
LPSHELLFOLDER psfFolder = NULL;
LPEXTRACTIMAGE pIExtract = NULL;
HRESULT hr;
ULONG chEaten = 0;
wchar_t buf[100];
SHGetDesktopFolder(&psfFolder);
memcpy(buf, L"c:\\test\\Thumbs.db", lstrlenW(L"c:\\test\\Thumbs.db") );
hr = psfFolder->ParseDisplayName(NULL, NULL, buf,
&chEaten,
&localPidl,
NULL);
hr = psfFolder->GetUIObjectOf(NULL, 1, (const ITEMIDLIST**)&localPidl,
IID_IExtractImage,
NULL, (void**)&pIExtract);
hr = pIExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority,
(SIZE*)28672, NULL, &dwFlags);
if(NULL == pIExtract)
return NULL;
if(NOERROR == hr) hr = pIExtract->Extract(&hBmpImage);
pIExtract->Release();
return hBmpImage;
}
*****************************
*Is that the way to read such format? Can I read all thumbnail imaes?
*In the (psfFolder->GetUIObjectOf) function the programe crashes. Any idea
what is the problem here?
thanks alot
date: Mon, 7 Jul 2008 00:09:01 -0700
author: Amer Huzayen Amer
Re: problem with reading Thumbs.db in windows shell
thanks alot for your answer.
please before that let me now if I will get the result I need which is the
images in the thumbs.db?
I notied that and I wrote another code, but the HRESULT return (0x80070002)
this error number after calling (psfWorkDir->GetUIObjectOf) function in the
below code:
*******************************
HRESULT 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, 2, (LPCITEMIDLIST*)&pidlURL,
IID_IExtractImage, NULL, (void**)&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;
}
***********************************
date: Mon, 7 Jul 2008 06:30:01 -0700
author: Amer Huzayen
|
|