I omitted a pretty significant point in my first mail in that I didn't
mention a hack/workaround to do the COM registration in HKCU as a
non-privileged login using standard registration code by overlaying HKCR
with HKCU\Software\Classes:
@contextmanager
def diddle_HKCR():
try:
hkey = RegOpenKey(HKEY_CURRENT_USER, r'''Software\Classes''')
RegOverridePredefKey(HKEY_CLASSES_ROOT, hkey)
yield
finally:
RegOverridePredefKey(HKEY_CLASSES_ROOT, None)
if __name__ == "__main__":
from comtypes.server.register import UseCommandLine
with diddle_HKCR():
UseCommandLine(Action)
This technique has worked with any pythoncom stuff I've done (which
admittedly is not all that much and all IDispatch-based)
> I would love to know how _ctypes.pyd is being called to create the
> inproc instance
I read through the ctypes source and see that DllGetClassObject imports
comtypes.server.inprocserver which ends up here:
try:
_debug("DllGetClassObject(clsid=%s, iid=%s)", clsid, iid)
cls = inproc_find_class(clsid)
if not cls:
return CLASS_E_CLASSNOTAVAILABLE
result = ClassFactory(cls).IUnknown_QueryInterface(None,
ctypes.pointer(iid), ppv)
_debug("DllGetClassObject() -> %s", result)
return result
except Exception:
_critical("DllGetClassObject", exc_info=True)
return E_FAIL
Noting that E_FAIL is defined as
E_FAIL = -2147467259 #0x80004005L
it looks like my code is generating an exception somewhere within
ClassFactory(cls).IUnknown_QueryInterface(None,ctypes.pointer(iid), ppv)
I put some side effects into my module code to create a file when the
module is loaded and I see the file being created as a
CLSCTX_INPROC_SERVER.
The LocalServer32 registration is:
C:\Python26\python.exe C:\work\foo\ext\mostl\action.py
However, when I try to create an instance via CLSCTX_LOCAL_SERVER then it
just re-registers the class. On looking through the source-code, it seems
like the option 'embedded' must be passed on the command-line but I do not
see that string anywhere in the registry in the
HKCU\CLID\guid\LocalServer32 value.
Apologies if I am mangling the terms horribly! I feel that I am missing
something really obvious and that if I could figure out how to get to the
debugging output that I could fix it up very quickly.
pjjH
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
comtypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users