7

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?

Mr.C64
  • 41,637
  • 14
  • 86
  • 162
  • Not an option. Simply add another configuration to your project that uses the Win32 target in addition to the x64 target. If your code is clean then you'll have no trouble generating both an x86 and an x64 version of your DLL. – Hans Passant Dec 06 '12 at 16:23
  • @HansPassant: That sounds like a legit answer. – John Dibling Dec 06 '12 at 16:25
  • @HansPassant: I also wonder if the 32-bit and 64-bit shell extensions should have _different_ GUIDs. – Mr.C64 Dec 06 '12 at 17:02
  • They should share the same GUID. registering the 32bit extension on a 64bit OS should cause it to be put into the 32bit compatibility section of the registry – Anya Shenanigans Dec 06 '12 at 17:23
  • @Petesh: But is a 64-bit build of the shell extension still required on 64-bit OS? Or does the 32-bit extension run fine in the 64-bit OS? – Mr.C64 Dec 06 '12 at 17:35
  • @HansPassant: If there's no possibility, then you may want to write an answer (possibly with proper link to some official MSDN documentation), and I'll mark it as thread answer. I was hoping there would be some form of "emulation" of 32-bit shell system under 64-bit Windows, but if there isn't anything like that, I'll follow the path of double 32-bit and 64-bit builds. – Mr.C64 Dec 06 '12 at 22:35
  • The 32-bit extension works fine in 32-bit applications running on the 64-bit OS. Explorer isn't a WOW application though. – Ben Voigt Dec 07 '12 at 02:34
  • It seems there are 3 "off topic" votes to close the question, but I believe this question is legitimate. – Mr.C64 Dec 07 '12 at 09:15

3 Answers3

9

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.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79
1

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.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • 2
    That's incorrect. Content menu handlers are in-process extensions and cannot be implemented as out-of-process. https://msdn.microsoft.com/en-us/library/windows/desktop/dd758089(v=vs.85).aspx. Distributed COM (DCOM) does not apply –  Jun 04 '15 at 16:18
  • @Micky your link doesn't support your claim. Have another reference? – Ben Voigt Jun 04 '15 at 16:22
  • Specifically _[The following list shows examples of extensions that can be implemented as either in-process or out-of-process extensions: IExecuteCommand ; IDropTarget; IExplorerCommandState](http://tinyurl.com/o37qowa)_; and _[Shortcut menu handlers, also known as **context menu handlers** or verb handlers, are a type of file type handler. Like all such handlers, they are in-process Component Object Model (COM) objects implemented as DLLs](http://tinyurl.com/pav7kvq)_; and _[Shell extension handlers are all in-process COM objects implemented as DLLs](http://tinyurl.com/q7fnb48)_. Yours? –  Jun 04 '15 at 16:37
  • @Micky: Your third link is wrong (the quote from your first link is the proof). The quote from your first link is a list of examples, i.e. not exhaustive. The second link does support your point. Why didn't you link that in the first place? – Ben Voigt Jun 04 '15 at 16:40
  • @MickyDuncan: But in your second link, the very next paragraph talks about ".exe handlers", which are out-of-process. – Ben Voigt Jun 04 '15 at 16:42
  • @Micky: The quote from your second link is also wrong, since https://msdn.microsoft.com/en-us/library/windows/desktop/dd758091(v=vs.85).aspx lists verb handler approaches that can be implemented out-of-process. – Ben Voigt Jun 04 '15 at 16:44
  • Still awaiting your citations. Particularly the DCOM one –  Jun 04 '15 at 16:52
  • @MickyDuncan: Right there in your own quote is proof that verbs can be implemented out-of-process, using `IExecuteCommand`. – Ben Voigt Jun 04 '15 at 16:54
  • That's a general purpose interface used in many types of extensions inc shell namespace extensions. Used by itself its a poor sibling to context menu handlers http://stackoverflow.com/questions/28197401/how-to-gray-out-some-context-menu-options-with-an-iexecutecommand-based-shell-ex –  Jun 04 '15 at 16:59
  • @Micky: Using it to implement verbs is described in https://msdn.microsoft.com/en-us/library/windows/desktop/dd758091(v=vs.85).aspx, with emphasis on the fact that out-of-process IS supported. – Ben Voigt Jun 04 '15 at 17:00
  • Verbs are not context menu handlers. You can have verbs in shell namespace extensions where **no** menu even exists –  Jun 04 '15 at 17:01
  • @Micky: Again, your own quote says "Shortcut menu handlers, also known as context menu handlers or verb handlers" – Ben Voigt Jun 04 '15 at 17:02
  • One cannot think to know shell extensions by reading a few sentences. I recommend any of the classic Wrox Press books. I wish you well –  Jun 04 '15 at 17:06
  • 1
    Are you going to expand your answer to outline how to make an out-of-process context menu handler? – SamB Sep 06 '15 at 17:24
0

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.

Mohammad Eskandari
  • 221
  • 1
  • 3
  • 8