views:

171

answers:

2

I'm trying to write a Windows Explorer thumbnail handler for our custom file type. I've got this working fine for the preview pane, but am having trouble getting it to work for the thumbnails.

Windows doesn't even seem to be trying to call the DllGetClassObject entry point.

Before I continue, note that I'm using Windows 7 and unmanaged C++.

I've registered the following values in the registry:

HKCR\CLSID\<my guid>
HKCR\CLSID\<my guid>\InprocServer32 (default value = path to my DLL)
HKCR\CLSID\<my guid>\InprocServer32\ThreadingModel (value = "Apartment")
HKCR\.<my ext>\shellex\{E357FCCD-A995-4576-B01F-234630154E96} (value = my guid)

I've also tried using the Win SDK sample, and that doesn't work. And also the sample project in this article (http://www.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/), and that doesn't work.

I'm new to shell programming, so not really sure the best way of debugging this. I've tried attaching the debugger to explorer.exe, but that doesn't seem to work (breakpoints get disabled, and none of my OutputDebugStrings get displayed in the output window). Note that I tried setting the "DesktopProcess" in the registry as described in the WinSDK docs for debugging the shell, but I'm still only seeing one explorer.exe in the task manager - so that "may" be why I can't debug it??

Any help with this would be greatly appreciated!

Regards, Dan.

+3  A: 

Hey Dan, I stumbled across this since you mentioned my blog ( codemonkeycodes.com ).

What problem are you having with my sample? Did you register you DLL using regsvr32? What version of Windows 7 are you on, 32 or 64?


Update:

I can't say what is or isn't working for you. I just downloaded the sample from my site, followed the directions and change the function STDMETHODIMP CThumbnailProvider::GetThumbnail... to look like

{ *phbmp = NULL; *pdwAlpha = WTSAT_UNKNOWN;

ULONG_PTR token;
GdiplusStartupInput input;
if (Ok == GdiplusStartup(&token, &input, NULL))
{
    //gcImage.LogBuffer();
    Bitmap * pBitmap = new Bitmap(188, 141);
    if( pBitmap )
    {
        Color color(0, 0, 0);
        pBitmap->GetHBITMAP(color, phbmp);
    }
}

GdiplusShutdown(token);

if( *phbmp != NULL )
    return NOERROR;

return E_NOTIMPL;

}

I registered the DLL and then created a new file with the proper extension, and tada, I had a nice black thumbnail.

I wish I could help you. Maybe you want to email me your code?

Jeremy
Hi. I'm using x64 Windows7. As it's not just your sample that's not working for me - it's both the MS samples and my own code that also isn't working - I'm guessing there's something else up. As I'm new to Windows shell programming (my background is with application and game development), I don't really know the best way of debugging it is. I've tried attaching my debugger (MS VS 2005) to explorer.exe, but I don't see any of my trace logs.
Dan
A silly question, and I'm sure you didn't overlook this, but did you register you DLL with the 64bit version of regsrv32?
Jeremy
Yep, I explicitly typed in \windows\system32\regsvr32.exe.Do you know at what point Windows should be calling my DllGetClassObject function? It would be useful to see if it's getting there.
Dan
Also the MS instructions for debugging a windows extension (http://msdn.microsoft.com/en-us/library/cc144064%28VS.85%29.aspx), doesn't work for Windows7 as when I click on shutdown in the startmenu, it shuts down straight away without displaying a shutdown dialogbox.
Dan
Updated my original post.
Jeremy
Thankyou for that. That does indeed create a black background for the thumbnail. However, I now can't stop it from being a black background. If I change your code to a different colour, it's still black. If I unregister the DLL; search the entire registry removing my GUID and file extension; search the entire computer deleting all entries of ThumbnailProvider.dll; then do a complete reboot - still black. Which leads me to presume that Windows is doing some kind of caching. If windows is caching, it would certainly explain why I'm having so much trouble getting it to work!
Dan
Just got an email from Jeremy which answers my problem. Added it here incase anyone else has a similar problem. Basically, I wasn't changing my test file inbetween changes of my DLL. So Windows was caching it. Creating a copy of the file refreshed the thumbnail. Thanks Jeremy - you're a star!!
Dan
A: 

I've exactly the same problem. I cant make SDK or any sample works. I need COM sample because I must call Microsoft.Jet.OLEDB.4.0 which works only on 32 bits system.

I couldnt make this work : ww.codemonkeycodes.com/2010/01/11/ithumbnailprovider-re-visited/

// this works if AnyCPU is specified when compiling. Cant make it works for x86 ww.mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2006/07/21/5884.aspx

// This was nice under XP works like a charm ww.codeproject.com/KB/shell/thumbextract.aspx

// this show Adobe had problems with thumbnail An MS with Office 2007 (32 bits) ! ww.pretentiousname.com/adobe_pdf_x64_fix/

Philippe