Thank you Tom.<div>I tried 'EnsureDispatch()' following your advice.</div><div>This is it.</div><div><div>>>> import win32com.client</div><div>>>> sh = win32com.client.gencache.EnsureDispatch('Shell.Autoplay')</div>
<div>Traceback (most recent call last):</div><div> File "<pyshell#4>", line 1, in <module></div><div> sh = wcc.gencache.EnsureDispatch('Shell.Autoplay')</div><div> File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 529, in EnsureDispatch</div>
<div> disp = win32com.client.Dispatch(prog_id)</div><div> File "C:\Python32\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch</div><div> dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)</div>
<div> File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName</div><div> return (_GetGoodDispatch(IDispatch, clsctx), userName)</div><div> File "C:\Python32\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch</div>
<div> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)</div><div>pywintypes.com_error: (-2147467262, 'Inteface is not supported', None, None)</div><div><br></div><div>Same error occured on 'Shell.Autoplay'. And so on my 'SMIEngine.SMIhost'.</div>
<div><br></div><div>Then I went tolaunch 'makepy.py'</div>I was asked to 'Select library'</div><div>But what is this 'library' mean ?</div><div>Nothin like 'Shell.autoplay' or 'SMIEngine'.</div>
<div><br></div><div>Sorry I'm not familiar with COM.</div><div><br></div><div>Regards</div><div> ikeya</div><div><br><div class="gmail_quote">2012/4/10 Tim Roberts <span dir="ltr"><<a href="mailto:timr@probo.com">timr@probo.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">takeshi ikeya wrote:<br>
> Anyone help me ?<br>
> I really appreciate win32extension.<br>
> I'm trying to use some 3'rd parties COM.<br>
><br>
> First I tested win32extension installation.<br>
><br>
> >>> import win32com.client<br>
> >>> sh = win32com.client.Dispatch('Shell.Application')<br>
> >>> sh.SetTime()<br>
><br>
> Goes OK.<br>
</div>> ...<br>
<div class="im">> Next step. I tried 'Shell.Autoplay'.<br>
> Simply because it's on the next apeerance.<br>
><br>
> >>> sa = win32com.client.Dispatch('Shell.Autoplay')<br>
</div>> ...<br>
> Traceback (most recent call last): ...<br>
<div class="im">> File "D:\Python27\lib\site-packages\win32com\client\dynamic.py",<br>
> line 85, in _GetGoodDispatch<br>
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,<br>
> pythoncom.IID_IDispatch)<br>
</div>> com_error: <a href="tel:%28-2147467262" value="+12147467262">(-2147467262</a> <tel:%28-2147467262>,<br>
<div class="im">> '\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',<br>
> None, None)<br>
> >>><br>
><br>
> Dispatch() returns error<br>
<br>
</div>-<a href="tel:2147467262" value="+12147467262">2147467262</a> is 0x80004002, which is E_NOINTERFACE.<br>
<br>
There are two different ways of talking to a COM server: "early binding"<br>
and "late binding".<br>
<br>
"Early binding" is what you use from C++. It means the COM client knows<br>
the full layout of the COM object, including all of the methods it<br>
supports, and in what order they appear in the function table. All COM<br>
objects support "early binding".<br>
<br>
"Late binding" is what you use from, for example, Visual Basic. With<br>
"late binding", the object supports an interface called IDispatch. I<br>
can use the IDispatch interface to ask the object about the methods it<br>
supports and the parameter types for each method. An object with<br>
IDispatch can be used by more clients, but it is somewhat painful to<br>
add. So, many objects only support "early binding".<br>
<br>
win32com.client.Dispatch uses late binding. Shell.Application supports<br>
IDispatch, but Shell.Autoplay does not, and apparently neither does<br>
SMIEngine.SMIHost. You get the E_NOINTERFACE error because the object<br>
does not support IDispatch.<br>
<br>
You can use early binding from Python by creating a proxy wrapper. You<br>
can do this by using the "makepy" command in the Python distribution, or<br>
by using win32com.client.gencache.EnsureDispatch instead of<br>
win32com.client.Dispatch.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Tim Roberts, <a href="mailto:timr@probo.com">timr@probo.com</a><br>
Providenza & Boekelheide, Inc.<br>
<br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
</font></span></blockquote></div><br></div>