[python-win32] COM Server and TypeLibraries.
obj._oleobj_.GetTypeInfoCount() = 0?
Timothy Toroni
timothy at torpedogames.com
Thu Aug 12 07:34:24 CEST 2004
Hello All,
I am working on making a python COM server work with Labview which
requires the type libraries for the IDispatch interface... Granted... at
the moment I'm not even able to have Makepy run on my objects. It blows
up as shown below.
I'm guessing my problem lies in that when I create an object, the
object.GetTypeInfoCount() returns 0, then object.GetTypeInfo() just blows
up. I tried making all this work with the pippo example. My com server
is modeled after it.
** Pippo not returning a PyITypeInfo object.
>>> o = Dispatch('Python.Test.Pippo')
>>> o._oleobj_.GetTypeInfoCount()
0
>>> o._oleobj_.GetTypeInfo()
Traceback (most recent call last):
File "<pyshell#19>", line 1, in -toplevel-
o._oleobj_.GetTypeInfo()
com_error: (-2147352567, 'Exception occurred.', None, None)
>>>
** Now because the above fails - the below also fails, which should call
the makepy thing which creates the python class with all the functions
locally defined.... I actually found the above "issue" from looking at
line 543 of gencache.py.
>>> oo = EnsureDispatch('Python.Test.Pippo')
Traceback (most recent call last):
File "<pyshell#35>", line 1, in -toplevel-
oo = EnsureDispatch('Python.Test.Pippo')
File "C:\Python23\Lib\site-packages\win32com\client\gencache.py", line
543, in EnsureDispatch
raise TypeError, "This COM object can not automate the makepy process
- please run makepy manually for this object"
TypeError: This COM object can not automate the makepy process - please
run makepy manually for this object
>>>
** Now if I take another working application... (for which makepy works
too)
>>> oo = Dispatch('Excel.Application')
>>> oo._oleobj_.GetTypeInfoCount()
1
>>> oo._oleobj_.GetTypeInfo()
<PyITypeInfo at 0x9b9e6c with obj at 0x14edbc>
>>>
** I get a PyITypeInfo object back. So what is the deal. What is not in
the Pippo COM server which causes this failure? I've registered the type
libraries.. in fact below I've attached the .IDL file that oleview dumps.
I'm rather stumped at this point. Any advice is much apprieached. I
realize that Python COM servers have come up in the past on this list
which use type libraries and I've gone over the messages... but I must be
missing something.
It seems like the object is not associating the type library with the
application?
73,
Timothy
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: pippo.tlb
[
uuid(41059C57-975F-4B36-8FF3-C5117426647A),
version(1.0),
helpstring("TestServer 1.0 Type Library"),
custom(DE77BA64-517C-11D1-A2DA-0000F8773CE9, 100663657),
custom(DE77BA63-517C-11D1-A2DA-0000F8773CE9, 1082621398),
custom(DE77BA65-517C-11D1-A2DA-0000F8773CE9, Created by MIDL version
6.00.0361 at Thu Apr 22 18:09:57 2004
)
]
library TESTSERVERLib
{
// TLib : // TLib : OLE Automation :
{00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface ITestServerApp;
interface IPippo;
[
uuid(49E44E89-5A72-4456-B1D5-68268A19E798),
helpstring("TestServerApp Class")
]
coclass TestServerApp {
[default] interface ITestServerApp;
};
[
odl,
uuid(50086EE8-F535-464B-806E-365ADBB727CF),
helpstring("ITestServerApp Interface"),
dual,
oleautomation
]
interface ITestServerApp : IDispatch {
[id(0x00000001), helpstring("method Test1")]
HRESULT Test1([out, retval] ITestServerApp** pVal);
[id(0x00000002), helpstring("method Test2")]
HRESULT Test2([out, retval] VARIANT* pVar);
[id(0x00000003), propget, helpstring("property MyProp1")]
HRESULT MyProp1([out, retval] long* pVal);
};
[
uuid(E19C0A68-F61C-450B-A974-A7BA6957829C),
helpstring("Pippo Class")
]
coclass Pippo {
[default] interface IPippo;
};
[
odl,
uuid(F1A3CC2E-4B2A-4A81-992D-67862076949B),
helpstring("IPippo Interface"),
dual,
oleautomation
]
interface IPippo : IDispatch {
[id(0x00000001), helpstring("method Method1")]
HRESULT Method1([out, retval] IPippo** val);
[id(0x00000002), propget, helpstring("property MyProp1")]
HRESULT MyProp1([out, retval] long* pVal);
};
};
--
Timothy Toroni, AB9GC, Sgt. York, timothy at torpedogames.com
http://www.torpedogames.com
More information about the Python-win32
mailing list