Generating thumbnails using IExtractImage

R

rose.kevin

Hi

I am trying to get Windows Explorer to display thumbnails for my own
custom filetype. I have found plenty examples out there telling me how
to extract thumbnails from explorer for your own use, but I want to go
the other way around.

I have implemented the IExtractImage interface:

[ComImportAttribute()]
[GuidAttribute("BB2E617C-0920-11d1-9A0B-00C04FC2D6C1")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
interface IExtractImage
{
void GetLocation(
[Out, MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszPathBuffer,
int cch,
ref int pdwPriority,
ref SIZE prgSize,
int dwRecClrDepth,
ref int pdwFlags);

void Extract(
out IntPtr phBmpThumbnail);
}

[Guid("907C0B30-CCDF-41f6-BBE3-C0DCB22BB2BC"), ComVisible(true)]
public class rageShellExtensions : IExtractImage, IShellExtInit
{
public rageShellExtensions() { }

const string clsid = "{907C0B30-CCDF-41f6-BBE3-C0DCB22BB2BC}";

void IExtractImage.GetLocation(
[Out, MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszPathBuffer,
int cch,
ref int pdwPriority,
ref SIZE prgSize,
int dwRecClrDepth,
ref int pdwFlags)
{
[Do something]
}

void IExtractImage.Extract(
out IntPtr phBmpThumbnail)
{
[Do something]

}
}

And I register myself with explorer as follows:

static public void Register()
{
Assembly asm = Assembly.GetExecutingAssembly();
RegistrationServices reg = new RegistrationServices();
reg.RegisterAssembly(asm,
AssemblyRegistrationFlags.SetCodeBase);
}

[System.Runtime.InteropServices.ComRegisterFunctionAttribute()]
static void RegisterServer(String zRegKey)
{
try
{
RegistryKey root;
RegistryKey rk;

// For Winnt set me as an approved shellex
root = Registry.LocalMachine;
rk =
root.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Shell
Extensions\\Approved", true);
rk.SetValue(clsid, "rageShellExtensions Shell
Extension");
rk.Close();

// Register for thumbnails
root = Registry.ClassesRoot;
rk =
root.CreateSubKey(".mtl\\shellex\\{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}");
rk.SetValue("", clsid);
rk.Close();
}
catch (Exception e)
{
[Handle bad things]
}
}


My problem is neither of my IExtractImage functions are getting called.
:( I've been googling all day and I'm stumped. Can anyone help me?

Thanks
Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top