[python-win32] SMIEngine(COM)

takeshi ikeya takeshi.ikeya at gmail.com
Wed Apr 11 13:20:22 CEST 2012


Thank you Tom.
I tried 'EnsureDispatch()' following your advice.
This is it.
>>> import win32com.client
>>> sh = win32com.client.gencache.EnsureDispatch('Shell.Autoplay')
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    sh = wcc.gencache.EnsureDispatch('Shell.Autoplay')
  File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line
529, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File "C:\Python32\lib\site-packages\win32com\client\__init__.py", line
95, in Dispatch
    dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line
108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line 85,
in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147467262, 'Inteface is not supported', None, None)

Same error occured on 'Shell.Autoplay'. And so on my 'SMIEngine.SMIhost'.

Then I went tolaunch  'makepy.py'
I was asked to 'Select library'
But what is this 'library' mean ?
Nothin like 'Shell.autoplay' or 'SMIEngine'.

Sorry I'm not familiar with COM.

Regards
  ikeya

2012/4/10 Tim Roberts <timr at probo.com>

> takeshi ikeya wrote:
> > Anyone help me ?
> > I really appreciate  win32extension.
> > I'm trying to use some 3'rd parties COM.
> >
> > First I tested win32extension installation.
> >
> > >>> import win32com.client
> > >>> sh = win32com.client.Dispatch('Shell.Application')
> > >>> sh.SetTime()
> >
> > Goes OK.
> > ...
> > Next step. I tried 'Shell.Autoplay'.
> > Simply because it's on the next apeerance.
> >
> > >>> sa = win32com.client.Dispatch('Shell.Autoplay')
> > ...
> > Traceback (most recent call last): ...
> >   File "D:\Python27\lib\site-packages\win32com\client\dynamic.py",
> > line 85, in _GetGoodDispatch
> >     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> > pythoncom.IID_IDispatch)
> > com_error: (-2147467262 <tel:%28-2147467262>,
> >
> '\x83C\x83\x93\x83^\x81[\x83t\x83F\x83C\x83X\x82\xaa\x83T\x83|\x81[\x83g\x82\xb3\x82\xea\x82\xc4\x82\xa2\x82\xdc\x82\xb9\x82\xf1',
> > None, None)
> > >>>
> >
> > Dispatch() returns error
>
> -2147467262 is 0x80004002, which is E_NOINTERFACE.
>
> There are two different ways of talking to a COM server: "early binding"
> and "late binding".
>
> "Early binding" is what you use from C++.  It means the COM client knows
> the full layout of the COM object, including all of the methods it
> supports, and in what order they appear in the function table.  All COM
> objects support "early binding".
>
> "Late binding" is what you use from, for example, Visual Basic.  With
> "late binding", the object supports an interface called IDispatch.  I
> can use the IDispatch interface to ask the object about the methods it
> supports and the parameter types for each method.  An object with
> IDispatch can be used by more clients, but it is somewhat painful to
> add.  So, many objects only support "early binding".
>
> win32com.client.Dispatch uses late binding.  Shell.Application supports
> IDispatch, but Shell.Autoplay does not, and apparently neither does
> SMIEngine.SMIHost.  You get the E_NOINTERFACE error because the object
> does not support IDispatch.
>
> You can use early binding from Python by creating a proxy wrapper.  You
> can do this by using the "makepy" command in the Python distribution, or
> by using win32com.client.gencache.EnsureDispatch instead of
> win32com.client.Dispatch.
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120411/346b335b/attachment.html>


More information about the python-win32 mailing list