[python-win32] Context menu handler as executable

Gertjan Klein gklein at xs4all.nl
Tue Aug 9 05:21:33 EDT 2016


Thomas Heller wrote:

> AFAIK, Shell extensions must be inproc servers, not local servers.  In
> other words, they must be DLLs not EXEs.

Thanks! That helps. As far as I can tell, py2exe is the only executable 
builder that can create a COM server DLL, so I'm trying to find out how 
to request it to do so. There is an example here:

http://www.py2exe.org/index.cgi/Py2exeAndWin32com

However, this talks about modules and packages; I have one single file. 
Could you (or anyone) steer me in the right direction?

The minimal setup.py (for ctmx.py I posted earlier) I've come up with is 
this:

from distutils.core import setup
import py2exe
import sys

class Target:
     def __init__(self, **kw):
         self.__dict__.update(kw)
         self.version = "1.0"

my_com_server_target = Target(
     description = "Contextmenu test",
     # use module name for win32com exe/dll server
     modules = ["ctxm.ShellExtension"],
     # specify which type of com server you want (exe and/or dll)
     create_exe = False,
     create_dll = True,
     )

setup(
     name="ContextMenuTest",
     # the following two parameters embed support files within
     # exe/dll file
     options={"py2exe": {"bundle_files": 1, }},
     zipfile=None,
     py_modules=["ctxm"],
     com_server=[my_com_server_target],
     )

In case it matters, I'm using Python version 3.4, pywin32 version 219, 
py2exe 0.9.2.2.

Regards,
Gertjan.




More information about the python-win32 mailing list