Using 32-bit shell extensions in Windows 7 64-bit

2019-02-13 01:55发布

问题:

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 extensions in 64-bit Windows, or must the shell extension be ported/rebuilt to 64-bit to be used in Windows 7 64-bit?

Are there any disadvantages / known issues in using 32-bit shell extensions in 64-bit operating systems?

32-bit apps run just fine in 64-bit Windows, but I'm not sure about shell extensions, since, if my understanding is correct, shell extensions are in-proc COM servers loaded into Explorer process, which should be a 64-bit process in 64-bit Windows...or is a form of "32-bit emulation" provided for 32-bit shell extensions running in 64-bit OS?

回答1:

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.



回答2:

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.



回答3:

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.