[python-win32] COM and Makepy when DLL and TLB are separated

Chris Brandson cbrandson at triant.com
Thu Dec 4 19:28:41 EST 2003


I checked and the DLL does have its own typelib, however am told that this
is a side effect of the build process and is not needed or used. What I am
trying to do is use a COM interface built for VB applications to access a C
DLL. We are exploring the possibility of allowing the construction of
plug-ins to our system in Python instead of VB, which is how they currently
are constructed. First step is to make sure that we can access the "core" C
libraries to retrieve and analyse data then step two will be to form this
into a plug-in with exports COM interface to VB master application.

Today: VB Master Application ->COM-> VB plugin ->COM-> COM wrapper to C DLL
Future: VB Master Application ->COM-> Python plugin ->COM-> COM wrapper to C
DLL

Eventually we can get this to work we will eliminate the COM interface to
the C DLL, but we will still need the COM interface back to the master VB
application.

Given that the wrapper for the DLL is not needed, as a further test, I
deleted files in the gen_py directory and rebuilt the file using makepy from
the type library only. I can then call create an object from the progid
thus:

tnt = win32com.client.Dispatch("TntCore5_0.DataFilePreprocessor")

However an attempt to invoke the init method produces:

tnt.Initialize()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "E:\Programs\Python22\lib\site-packages\win32com\client\dynamic.py",
line 454, in __getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: TntCore5_0.DataFilePreprocessor.Initialize

If I look in the generated gen_py file there is a vtable entry:

IDataFilePreprocessor_vtables_ = [
	('Cancel', 1610678272, (), (3, 0, None), ()),
	('Cancelled', 1610678273, ((16395,10,None), ), (3, 0, None), ('pRes',)),
	('Initialize', 1610678274, (), (3, 0, None), ()),
...<more deleted>...

And


VTablesToClassMap = {
	'{082534F5-5424-11D4-A4E0-005004D6E3AF}' : 'IDataFilePreprocessor',
...<more deleted>...


VTablesNamesToIIDMap = {
	'IDataFilePreprocessor' : '{082534F5-5424-11D4-A4E0-005004D6E3AF}',
...<more deleted>...
}

However I notice that the CLSIDToClassMap is empty:

CLSIDToClassMap = {
}
CLSIDToPackageMap = {}
win32com.client.CLSIDToClass.RegisterCLSIDsFromDict( CLSIDToClassMap )
VTablesToPackageMap = {}

Is there an issue because there is no CLSIDToPackageMap? Also I notice that
the Class name is IDataFilePreprocessor. I know that I is for interface but
am not sure when COM used I interface and when it uses the method directly.

I appreciate your help!

Regards,

- Chris




-----Original Message-----
From: Mark Hammond [mailto:mhammond at skippinet.com.au]
Sent: Thursday, December 04, 2003 3:05 PM
To: 'Chris Brandson'; python-win32 at python.org
Subject: RE: [python-win32] COM and Makepy when DLL and TLB are
separated


tlb and the dlls should be able to work when they are discrete, and does for
most other objects.  Even when they are in the same file, it is quite common
that the typelib is just a "blob" in the file anyway.

makepy just uses LoadRegTypeLib in most cases, but depending on the params
you pass, may open using the .tlb name directly.

I'm not completely clear on your environment though.  It sounds like your
DLL *also* has a typelib - if you try and run makepy over a DLL without a
typelib it will fail.  If your DLL attempting to extend interfaces in the
.tlb?  If not, why is there type info available in both the .tlb and the
.dll?

Mark.

> -----Original Message-----
> From: python-win32-bounces at python.org
> [mailto:python-win32-bounces at python.org]On Behalf Of Chris Brandson
> Sent: Thursday, 4 December 2003 5:50 AM
> To: python-win32 at python.org
> Subject: [python-win32] COM and Makepy when DLL and TLB are separated
>
>
> I need to access an InProc COM interface which was originally
> designed for
> VB and has a separate type library (".tlb" file) and DLL. An
> additional
> problem is that some of the arguments are ByRef and are
> modified during
> invocation. Makepy can generate source files for both the DLL
> and typelib.
> The typelib has interfaces defined but CLSIDToClassMap is
> empty. The DLL has
> a  CLSIDToClassMap for the classes but no interfaces defined
> (they are in
> the tlb). I had hoped that win32com.client would combine TLB
> and DLL and
> allow access, but when I create the top level object from the
> ProgID with
> Dispatch, none of the properties or methods seen to be found e.g.
> "AttributeError: '<win32com.gen_py.<DLL COM entry>.<interface
> name>' object
> has no attribute 'Initialize'. Is there documentation
> somewhere on what
> makepy is actually doing. There is some info in "Python Programming on
> Win32", but I haven't been able to map what is there to my
> case with a DLL
> and TLB.
>
> Is there something I need to do to link the DLL and TLB or is
> the issue
> related to the fact that just about every method needs
> arguments passed by
> reference?
>
> Any assistance would be greatly appreciated.
>
> Thanks,
>
> - Chris
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32






More information about the Python-win32 mailing list