[python-win32] How to Impletments COM Interface: IInternetProtocol
Zhao Dapu
zhaodapu at gmail.com
Wed May 23 12:59:54 CEST 2007
Hi, all
I want to implements an Asynchronous Pluggable Protocol handler, which
can handle a custom protocol like "http" or "mk". Follow the
instruction of MSDN, I must Implements at least 3 interfaces:
IInternetProtocol, IInternetProtocolRoot and IClassFactory. But I'm
not clear how to do this and didn't find any clue in the win32com
documents.
Shoule I use makepy first to generate the a wrap py-file? But I don't
know the name of the typelib. I'm a newbie in COM. I also find any
thing about "IInternetProtocol" in my registry.
Below is some code I thought it should be. Without the
_com_interfaces_ lines, it works( i.e. I can create the COM object and
call the methods). But now it will generate many errors.
Any clue is appreciated!
import win32com
class MyProtocol:
_com_interfaces_ = ['IInternetProtocol',
'IInternetProtocolRoot',
'IClassFactory',]
_com_interfaces_ = ['IDispatch']
_reg_clsid_ = '{F662AB76-9BE9-440F-9F33-42750C86EA2C}'
_reg_progid_ = 'MyProtocol'
_public_methods_ = ['Read', 'Seek']
def __init__(self):
print "create a com obj"
# IInternetProtocol
def Read(self, pv, cb, pcbread):
print "Method called: Read 1"
def Seek(self, dlibMove, dwOrigin, plibNewPosition):
print "Method called: Seek"
# IInternetProtocolRoot
def Start( self, szUrl, pOIProtSink, pOIBindInfo, grfPI, dwReserved):
print "Method called: Start"
def Abort(hrReason, dwOptions):
print "Method called: Abort"
Dapu
More information about the Python-win32
mailing list