Skute
2005-09-20 08:55:41 UTC
Hi,
Ive got a problem which is seriously plaguing me.
Im using the following code:
HBITMAP ExtractThumbnail(IShellFolder* pParentFolder, LPCITEMIDLIST
pidl)
{
CComPtr<IExtractImage> pExtract;
HBITMAP hBmpImage = NULL;
HRESULT hr = S_OK;
hr = pParentFolder->GetUIObjectOf(NULL, 1, &pidl, IID_IExtractImage,
NULL, reinterpret_cast<void **>(&pExtract));
if (pExtract != NULL) // Could be an early shell version where thumbs
werent supported
{
OLECHAR wszPathBuffer[MAX_PATH];
DWORD dwPriority = 0;
DWORD dwFlags = IEIFLAG_SCREEN;
SIZE szImage = {96, 96};
hr = pExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority,
&szImage, 32, &dwFlags);
// even if we've got shell v4.70+, not all files support thumbnails
if (hr == NOERROR)
hr = pExtract->Extract(&hBmpImage);
if (hBmpImage != NULL && hr != NOERROR)
{
::DeleteObject(hBmpImage);
hBmpImage = NULL;
}
}
return hBmpImage;
}
This code works beautifully in a single threaded application, but as
soon as i call this code in a separate thread, it locks up the GUI
(which is odd because its running in a separate thread!).
Has anyone got any clues as to why this may be happpening?
Im defiantely initialising COM etc.
The actual lock up occurs on the call to pExtract->Extract(&hBmpImage).
And usually occurs with the "My Shapes" directory in "My Documents". It
just pauses for about 3 seconds, then returns with hr = E_FAIL.
This is driving me nuts, please help.
Thanks,
Ive got a problem which is seriously plaguing me.
Im using the following code:
HBITMAP ExtractThumbnail(IShellFolder* pParentFolder, LPCITEMIDLIST
pidl)
{
CComPtr<IExtractImage> pExtract;
HBITMAP hBmpImage = NULL;
HRESULT hr = S_OK;
hr = pParentFolder->GetUIObjectOf(NULL, 1, &pidl, IID_IExtractImage,
NULL, reinterpret_cast<void **>(&pExtract));
if (pExtract != NULL) // Could be an early shell version where thumbs
werent supported
{
OLECHAR wszPathBuffer[MAX_PATH];
DWORD dwPriority = 0;
DWORD dwFlags = IEIFLAG_SCREEN;
SIZE szImage = {96, 96};
hr = pExtract->GetLocation(wszPathBuffer, MAX_PATH, &dwPriority,
&szImage, 32, &dwFlags);
// even if we've got shell v4.70+, not all files support thumbnails
if (hr == NOERROR)
hr = pExtract->Extract(&hBmpImage);
if (hBmpImage != NULL && hr != NOERROR)
{
::DeleteObject(hBmpImage);
hBmpImage = NULL;
}
}
return hBmpImage;
}
This code works beautifully in a single threaded application, but as
soon as i call this code in a separate thread, it locks up the GUI
(which is odd because its running in a separate thread!).
Has anyone got any clues as to why this may be happpening?
Im defiantely initialising COM etc.
The actual lock up occurs on the call to pExtract->Extract(&hBmpImage).
And usually occurs with the "My Shapes" directory in "My Documents". It
just pauses for about 3 seconds, then returns with hr = E_FAIL.
This is driving me nuts, please help.
Thanks,