1

I am trying to create a shell extension context menu and icon overlay. I have successfully registered and seen a context menu show up when right clicking and the menu clicks are correctly responding to the code when running the program through Python.

My issue is when I try to compile the Python code to an executable with cx_Freeze or py2exe. It builds the executable and running the executable creates a registry entry, but no menu shows up when right clicking after restarting explorer.exe.

I thought cx_Freeze or py2exe would be able to register the context menu or overlay and have it talk to the code within the exe. Do I need to make a dll file? I am not very familiar with com servers so anyone who has experience with shell extensions would be greatly appreciated.

I have more details if requested/needed.

Kyle K
  • 21
  • 5
  • Shell extension must be inproc COM server. It means you must create dll instead of exe. – Denis Anisimov Jun 27 '14 at 18:16
  • @DenisAnisimov okay, so I have tried that with py2exe. The issue I ran into was how to register the inProc COM server to point to the created dll that py2exe made. Using the sample code here [Python Shell](http://stackoverflow.com/questions/10833710/windows-explorer-context-menus-with-sub-menus-using-pywin32) it registers a local server32 key. – Kyle K Jul 02 '14 at 16:38
  • "how to register" - what it means? You don`t know how to write registration code or you don`t know how to register your shell extension in the Windows? – Denis Anisimov Jul 02 '14 at 17:25
  • Well, I know the code to register a key that says InProc but I don't know if the dll that py2exe creates is correct. I am unfamiliar with how COM servers work. Do I create a dll of this sample [code](http://stackoverflow.com/questions/10833710/windows-explorer-context-menus-with-sub-menus-using-pywin32) and create another python script to register an InProc key to point to the dll? – Kyle K Jul 02 '14 at 21:55
  • @DenisAnisimov I've looked at how tortoiseHG does their context menu and they have an InProc server pointing to a dll. Using a dll explorer the functions show up as DLLCanUnloadNow and DLLGetClassObject. Is this what I need to call my script? – Kyle K Jul 04 '14 at 15:28

1 Answers1

1

I was able to get the context menu registered through a dll following the steps in this link. I ended up using py2exe for 2.7 and I am not sure if the setup they used is what fixed it or if I needed to use regsvr32 when registering the dll instead of the self registry executable. I also used a patched py2exe that is in the answer of the link

Link: Com server build using Python on 64-bit Windows 7 machine

Community
  • 1
  • 1
Kyle K
  • 21
  • 5