SMIEngine(COM)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

SMIEngine(COM)

takeshi ikeya
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.

My windows Registry is

HKEY_CLASS_ROOT
    ...
    Shell.Application
    Shell.Autoplay
    ...
    SMIEngine.SMIHost  ... I want to use this (Animatics's servo)
    SMIEngine.SMIScan

  SMIEngine is explained herer

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 "<pyshell#5>", line 1, in <module>
    sa = win32com.client.Dispatch('Shell.Autoplay')
  File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "D:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  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: <a href="tel:%28-2147467262" value="+12147467262" target="_blank" style="color:rgb(17,85,204)">(-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
And 'SMIEngine.SMIHost' (this is what I'm trying)

>>> smi = win32com.client.Dispatch('SMIEngine.SMIHost')

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    smi = win32com.client.Dispatch('SMIEngine.SMIHost')
  File "D:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "D:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  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: <a href="tel:%28-2147467262" value="+12147467262" target="_blank" style="color:rgb(17,85,204)">(-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)
>>> 

returns same error.

What is the error of Dispatch()?
I really expecting your advice.

Regards

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

Tim Roberts
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, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

takeshi ikeya
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 <[hidden email]>
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: <a href="tel:%28-2147467262" value="+12147467262">(-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

-<a href="tel:2147467262" value="+12147467262">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, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

Tim Roberts
takeshi ikeya wrote:
> Thank you Tom.
> I tried 'EnsureDispatch()' following your advice.
> ...
> pywintypes.com_error: (-2147467262, 'Inteface is not supported', None,
> None)
>
> Same error occured on 'Shell.Autoplay'. And so on my 'SMIEngine.SMIhost'.

Not every COM object was intended to be used by the "general public".
There is no public definition that corresponds to the class ID for
Shell.Autoplay.


> 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.

Well, that's a problem, if you plan to use COM objects.  It is
worthwhile to do a little reading about COM basics.

In order to use a COM object, somehow your application has to learn what
functions that object provides, and what parameters each function
expects.  You can't just make that up.  That can be done in three basic
ways.  (1) If the object was designed only to be used from C++, you
might have a C++ header file that describes the object.  (2) If the
object was designed for "late binding", it will support the IDispatch
interface.  (3) If the object was designed for "early binding", there
will be a "type library" that includes all of the definitions.

A type library contains a collection of COM class definitions and
interface definitions in a partly compiled form.  That's what makepy.py
wants.  When you installed the SMI product, it registered its objects.
If it also registered its type library, you can use that to build the
Python interface.  Note that the name of a type library often includes
the manufacturer, so look for "Animatics SMIEngine".

Animatics says on their web site that the SMIEngine interface works with
Python.  Have you considered contacting them for support?

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

takeshi ikeya
Thank you Tim. Yes.
I'm not familiar with COM, but Animatics'manual about SMIengine explains every objects and their interfaces.
So I think, if I can get an instance of them, I can try and go ahead..
I also contacted with Animatics engineer through their agent.
And their answer is

"I know little about Python.
Most of the information I have seen indicates using ctypes.

And they asked

"Why not use  C++ ?"

They adviced using 'ctypes', but I think 'ctypes' is for ordinary DLL.
The 'ctypes' can't handle COM, and can't create an instance.

Or, their advice is right ?
I should use 'ctypes' ?

I'd like to go all in Python.

Regards
  ikeya
 


2012/4/12 Tim Roberts <[hidden email]>
takeshi ikeya wrote:
> Thank you Tom.
> I tried 'EnsureDispatch()' following your advice.
> ...
> pywintypes.com_error: <a href="tel:%28-2147467262" value="+12147467262">(-2147467262, 'Inteface is not supported', None,
> None)
>
> Same error occured on 'Shell.Autoplay'. And so on my 'SMIEngine.SMIhost'.

Not every COM object was intended to be used by the "general public".
There is no public definition that corresponds to the class ID for
Shell.Autoplay.


> 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.

Well, that's a problem, if you plan to use COM objects.  It is
worthwhile to do a little reading about COM basics.

In order to use a COM object, somehow your application has to learn what
functions that object provides, and what parameters each function
expects.  You can't just make that up.  That can be done in three basic
ways.  (1) If the object was designed only to be used from C++, you
might have a C++ header file that describes the object.  (2) If the
object was designed for "late binding", it will support the IDispatch
interface.  (3) If the object was designed for "early binding", there
will be a "type library" that includes all of the definitions.

A type library contains a collection of COM class definitions and
interface definitions in a partly compiled form.  That's what makepy.py
wants.  When you installed the SMI product, it registered its objects.
If it also registered its type library, you can use that to build the
Python interface.  Note that the name of a type library often includes
the manufacturer, so look for "Animatics SMIEngine".

Animatics says on their web site that the SMIEngine interface works with
Python.  Have you considered contacting them for support?

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32


_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

Tim Roberts
takeshi ikeya wrote:
>
> I'm not familiar with COM, but Animatics'manual about SMIengine
> explains every objects and their interfaces.
> So I think, if I can get an instance of them, I can try and go ahead..
> I also contacted with Animatics engineer through their agent.
> ...
> And they asked
>
> "Why not use  C++ ?"

That's a very poor excuse for an answer on their part, since their web
site SPECIFICALLY says this:

    SMIEngine is based on the Windows Component Object Model (COM) and
    works with:

      * Microsoft C++
      * Borland C++
      * Microsoft Visual Basic (VB)
      * VBA (Visual Basic for Applications)
      * MS.Net environment
      * Borland Delphi
      * Pascal
      * Python
      * LabView (when installed as an Active-X component)


>
> They adviced using 'ctypes', but I think 'ctypes' is for ordinary DLL.
> The 'ctypes' can't handle COM, and can't create an instance.
>
> Or, their advice is right ?
> I should use 'ctypes' ?

You are correct, they are wrong.  ctypes is for normal DLLs.  There is a
"comtypes" module that provides a ctypes-like interface for COM objects,
but that should not be necessary.  Their web site advertises Python
support.  They ought to be able to tell you how to do it.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32
Reply | Threaded
Open this post in threaded view
|

Re: SMIEngine(COM)

Tim Roberts
takeshi ikeya wrote:
>
> I showed your mail to the agent of Animatics.
> He promised that he'll find a good software engineer in Animatics.
> and make him find some answer.

That seems like exactly the right thing to do.

> But I am afraid....

Well, the only fear is that it will take too long.  If they can show you
one example, you can take it from there.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/python-win32