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, t...@probo.com Providenza & Boekelheide, Inc. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32