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.

5
  • Shell extension must be inproc COM server. It means you must create dll instead of exe. Commented Jun 27, 2014 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 it registers a local server32 key. Commented Jul 2, 2014 at 16:38
  • "how to register" - what it means? You dont know how to write registration code or you dont know how to register your shell extension in the Windows? Commented Jul 2, 2014 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 and create another python script to register an InProc key to point to the dll? Commented Jul 2, 2014 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? Commented Jul 4, 2014 at 15:28

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.