Maybe manifest problem with _ctypes.pyd ?
John Janecek <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
I attempted to convert old code from comtypes over to new comtypes.
It is a BHO.
I manually added the BHO entry into the registry.
When I start internet explorer i get a runtime error loading C library.
I noticed that in registry _ctypes.pyd is the com server.
I could be 100% wrong. But i think maybe _ctypes.pyd needs a manifest.
I am running IE8, windows XP SP3 and python 2.64
If anyone can give me any pointers :)
Thanx
here is my code
#bho.py
from ctypes import *
from ctypes.wintypes import WORD, DWORD, BOOL
from comtypes import
STDMETHOD,COMMETHOD,COMObject,CLSCTX_INPROC_SERVER,IUnknown, GUID,
STDMETHOD, HRESULT
from comtypes.hresult import *
from comtypes.server.register import Registrar,register,unregister
from wraptools import wraps
import logging
LOG_FILENAME = 'D:\\mybho.txt'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
##@wraps(register)
#def register_wrap(original_register,cls) :
# try :
# cls._get_registrar().register(cls)
# except AttributeError :
# original_register(cls)
#
##@wraps(unregister)
#def unregister_wrap(original_unregister,cls):
# try :
# cls._get_registrar().unregister(cls)
# except AttributeError :
# original_unregister(cls)
class IObjectWithSite(IUnknown):
_iid_ = GUID("{FC4801A3-2BA9-11CF-A229-00AA003D7352}")
_idlflags_ = []
#_methods_ = [
# (STDMETHOD(HRESULT, "SetSite", PIUnknown)),
# (STDMETHOD(HRESULT, "GetSite", POINTER(c_void_p), REFIID))]
#[
#COMMETHOD([], HRESULT,
# "SetSite",
# (['in'],POINTER(IUnknown),"pUnkSite")
# ),
#COMMETHOD([],HRESULT,
# "GetSite",
# (['in'],POINTER(GUID),"riid"),
# (['out'],POINTER(c_void_p),"ppvSite")
# )
#]
class PythonBHORegistrar(Registrar):
def _registry_entries(self,cls):
print "_registry_entries"
table = Registrar.build_table(self,cls)
HKLM = _winreg.HKEY_LOCAL_MACHINE
BHO_KEY =
("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper
Objects\\")
# rootkey, subkey, valuename, value
table.extend([(HKLM, BHO_KEY+cls._reg_clsid_,"",None)])
return table
class PythonBHO(COMObject):
_reg_threading_ = "Apartment"
_reg_clsid_ = "{693D1AC0-2D77-11D8-9B9E-FB41F7E93A45}"
_reg_progid_ = "PythonBHO"
_com_interfaces_ = [IObjectWithSite]
_reg_clsctx_ = CLSCTX_INPROC_SERVER
def _get_registrar(cls):
return PythonBHORegistrar()
_get_registrar = classmethod(_get_registrar)
def IObjectWithSite_SetSite(self,this,pUnkSite):
logging.debug('IObjectWithSite_SetSite')
return S_OK
if __name__ == "__main__":
#python myserver.py /regserver
#unregserver
logging.debug('XXXXXXXXXXXXXXXXXXXXXXXXXX')
from comtypes.server.register import UseCommandLine
UseCommandLine(PythonBHO)
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users