What does _com_interfaces_ do?

215 views Asked by At

I'm trying to understand the COM server examples of , and in win32comext/shell/demos/servers/icon_handler.py I saw the line

_com_interfaces_ = [shell.IID_IExtractIcon, pythoncom.IID_IPersistFile]

While that pretty clearly refers to an IconHandler having to implement the IExtractIcon and IPersistFile interfaces, I cannot find any documentation where _com_interfaces_ is actually used. It is nowhere to be seen in win32com.server.register or win32com.server.localserver.py, so neither registration nor the server call seem to actually use this. Is there any documentation on _com_interfaces_?

1

There are 1 answers

2
Martijn Pieters On BEST ANSWER

_com_interfaces_ is an optional attribute a Server Policy looks for:

_com_interfaces_

Optional list of IIDs exposed by this object. If this attribute is missing, IID_IDispatch is assumed (ie, if not supplied, the COM object will be created as a normal Automation object.

The list is used to answer QueryInterface enqueries, see the win32com.server.policy module to see how this is being used, specifically the BasicPolicy._wrap() and BasicPolicy._QueryInterface_ methods.