I\'d like to develop a shell extension (context menu handler) compatible with both Windows XP SP2 (32-bit) and Windows 7 64-bit.
Is it possible to run 32-bit shell
A shell extension is just a DLL, and the rule is that 32-bit applications can only load 32-bit DLLs, and 64-bit applications can only load 64-bit DLLs. There is no way around this.
A 32-bit shell extension may still be useful on a 64-bit system as it means that any 32-bit third-party applications that load shell extensions will work. For example, TortoiseSVN ships with and installs both 32- and 64-bit versions, and so on 64-bit Windows you can still access TortoiseSVN context menus from 32-bit applications (like a third-party file manager).
But Explorer itself is 64-bit native on 64-bit Windows and so you need a 64-bit version of your extension if you want it to work in Explorer.
Shell extensions are COM components. If you install it as an out-of-process server, Windows (DCOM) should take care of all the 32 <-> 64-bit marshalling.
The MIDL compiler will then create the 64-bit stub which loads in process.
You can use a 32-bit explorer, like xplorer² in 64-bit Windows. They can handle 32-bit DLL extensions which may use for as searching content, preview data and those also display in context menu. The built-in explorer is 64-bit, which ignores 32-bit extensions.