[python-win32] How to Impletments COM Interface: IInternetProtocol

Zhao Dapu zhaodapu at gmail.com
Wed May 23 21:49:17 CEST 2007


Hi, Steve,

Thank you for your information. I've read chapter 12 in detail, some
concepts are clear. But I still don't get it. Maybe I miss something.

1. I need to make a COM server. In the book, it just told how to
implements user-defined interfaces. How do I implement some system
interfaces, like IInternetProtocol. I supposed if there is a wrap
class of the interfaces, I can just inherit the class. The code maybe
like this:

class MyProtocol(PyIInternetProtocol, PyIClassFactory):
    ......

or like this:

class MyProtocol:
    _com_interfaces_ = ['IInternetProtocol', 'IClassFactory']
    ......

But these are not the real thing. There are no such wrap class
PyIInternetProtocol.

2. Makepy can create wrap classed of a typelib. The generated wrap
class can be used in a COM client (for early-bound and constants). Do
I need to use it when I create a sever-side COM object? As question 1
said , generating wrap class and inherit it?

Even the answer is Yes,  I still don't know which typelib it is. I
didn't find it in the typelib list.
How can I know which typelib defines these interfaces?

3. This question is not about python or PythonCOM. In my opinion,
every interface should have a entry int the registry. But I don't find
any information about IInternetProtocol. I found the IID of these
interfaces by google. They are not in my registry, except the last one
(IInternetSecurityMananer). They have similar IIDs and all implemented
in urlmon.dll. It puzzles me.

IInternetProtocol
"{79EAC9E4-BAF9-11CE-8C82-00AA004BA90B}"
IInternetProtocolInfo
"{79EAC9EC-BAF9-11CE-8C82-00AA004BA90B}"
IInternetProtocolRoot
"{79EAC9E3-BAF9-11CE-8C82-00AA004BA90B}"
IInternetProtocolSink
"{79EAC9E5-BAF9-11CE-8C82-00AA004BA90B}"
IInternetSecurityManager
"{79EAC9EE-BAF9-11CE-8C82-00AA004BA90B}"


If the questions are stupid, please just let me know why.

Dapu

2007/5/23, steve george <steve_geo at optusnet.com.au>:
> Did you read Chapter 12
> http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html
>
> Zhao Dapu wrote:
> > 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
> > _______________________________________________
> > Python-win32 mailing list
> > Python-win32 at python.org
> > http://mail.python.org/mailman/listinfo/python-win32
> >
> >
>
>


More information about the Python-win32 mailing list