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

Larry Bates lbates at syscononline.com
Fri Dec 5 08:24:43 EST 2003


I may be WAY out of line here, but if the .DLL is a normal
C .DLL you can call it directly by using the following:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146847

Hope information helps.

Larry Bates



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






------------------------------

Message: 5
Date: Thu, 4 Dec 2003 16:51:31 -0800
From: Tyler Mitchell <TMitchell at lignum.com>
Subject: [python-win32] XML-RPC example - was beginner's question on
	network	programming
To: "Mark Hammond" <mhammond at skippinet.com.au>
Cc: python-win32 at python.org
Message-ID:
	<OF42760322.78421607-ON88256DF2.00818340-88256DF3.0004B736 at lignum.com>
Content-Type: text/plain; charset=US-ASCII






Mark, what you didn't say was: "Contribute back you silly goose".  I should
have thought of that a while ago, thanks for the reminder!
I was kinda holding out waiting for someone else to point out a better link
or say they've already got it figured already ;)

So here's an example of what I've done:

Pre-requisites include xmlrpclib and SimpleXMLRPCServer libraries.  Let me
know if you need a hand finding them.

----------
Here's the server-side script, keeping it in an order usual for tutorial
purposes:

>>>class MyFuncs:
>>>  def add(self, x, y):
>>>    return x + y

>>>from SimpleXMLRPCServer import SimpleXMLRPCServer
>>>server = SimpleXMLRPCServer((localhost,8000))
>>>server.register_instance(MyFuncs())
# The server will run until you hit Control-C or the like

---------
Here's the client-side script to access above said function:

>>>from xmlrpclib import Server
>>>myserver = Server("http://localhost:8000")
>>>print myserver.add(5,6)
11  #Printed results here, but could also pass the object (?) back as
well...

>>>mytotal = myserver.add(5,6)
>>>print mytotal
11






             "Mark Hammond"
             <mhammond at skippin
             et.com.au>                                                 To
             Sent by:                  "'Tyler Mitchell'"
             python-win32-boun         <TMitchell at lignum.com>
             ces at python.org                                             cc
                                       python-win32 at python.org
                                                                    Fax to
             12/04/2003 03:12
             PM                                                    Subject
                                       RE: [python-win32] beginner's
                                       question on network programming










> I should say, I found the documentation of XML-RPC, specifically for
> python, to be sketchy and irritating from a new user
> perspective.  So I
> suggest you don't waste your time reading until you've found a good
> tutorial.  I was barely able to find a good server example of
> xml-rpc in
> python!  If you or others on the list would like, I could
> walk you through
> my  most simple application as a tutorial.

As a side note, most of the Python/extensions docs follow this cycle:
* Technically smart person writes cool code, and very sketchy docs
(generally written for someone just like him/her)
* 500 people scratch their head, stumble around, post to mailing lists and
manage to put together a vague answer.  Many fail.
* One of the 500 picks up the ball and contributes real documentation.
* The next 500 people trying to use it have a much better life.

This is, unfortunately, the current nature of Open Source.  As Open Source
moves up the food chain, I hope to see that change, but it won't be soon.

While it may seem formidable, submitting docs and examples needn't be that
hard, and will generally be gratefully accepted.

Mark.


_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32





------------------------------

Message: 6
Date: Thu, 04 Dec 2003 16:18:18 -0800
From: "Greg Lee" <gphst at hotmail.com>
Subject: [python-win32] reliably controlling IE (Dispatch vs
	DispatchEx)
To: python-win32 at python.org
Message-ID: <BAY7-F63yXvEbjkyqU70000c5d3 at hotmail.com>
Content-Type: text/plain; format=flowed

I'm using code like this to display text in IE from within a Tkinter
application:

           # magic argument list generated by makepy.py -i for Microsoft
Internet Controls

win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',
0, 1, 1)
            self.iexplorer =
win32com.client.DispatchEx('InternetExplorer.Application.1")
            self.iexplorer.Visible = 1
            self.iexplorer.Navigate(contents)
            win32gui.ShowWindow(self.iexplorer.HWND, 1)   # winuser.h:SW_

I'm using DispatchEx rather than the conventional Dispatch because I've
noticed that if I have a Windows Explorer running and use Dispatch, then the
contents sometimes appears in the right-hand pane of the Windows Explorer
rather than in a new instance of InternetExplorer.  Using DispatchEx "seems"
to do the right thing, but I'm reluctant to rely on this as a fix for an
intermittent problem.  Any thoughts from the experts?

There is a 4 August posting stating that DispatchEx was necessary when you
want two instances of of IE, as in:
        ie1 = Win32com.client.DispatchEx('InternetExplorer.Application.1')
        ie2 = Win32com.client.DispatchEx('InternetExplorer.Application.1')

_________________________________________________________________
Browse styles for all ages, from the latest looks to cozy weekend wear at
MSN Shopping.  And check out the beauty products! http://shopping.msn.com




------------------------------

Message: 7
Date: Fri, 5 Dec 2003 09:42:36 +0800
From: "Cheeng, Shu-Chin SC SITI-ITDDG12" <Shu-Chin.Cheeng at Shell.com>
Subject: [python-win32] RE: Python-win32 Digest, Vol 9, Issue 3
To: <python-win32 at python.org>
Message-ID:
	<6F825BFCBC2CDA4CB17564B98AF491FC02171B07 at cbj-s-340.asia-pac.shell.com>

Content-Type: text/plain; charset="iso-8859-1"

hi all,
Me Too...
Python 223+win32all-162
Can't find Gen_py and Import error...once using win32com.client.*
Regards,
Cheeng Shu Chin
SA-Messaging
Shell Information Technology International
2340 Century Square, Jalan Usahawan, 63000 Cyberjaya, Selangor D.E., Malaysia

Tel: +603-8313 3787 Fax:  3900 Other Tel: +6013 630 1682
Email: shu-chin.cheeng at shell.com
Internet: http://www.shell.com


-----Original Message-----
From: python-win32-request at python.org [mailto:python-win32-request at python.org]
Sent: Thursday, December 04, 2003 1:04 AM
To: python-win32 at python.org
Subject: Python-win32 Digest, Vol 9, Issue 3


Send Python-win32 mailing list submissions to
	python-win32 at python.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mail.python.org/mailman/listinfo/python-win32
or, via email, send a message with subject or body 'help' to
	python-win32-request at python.org

You can reach the person managing the list at
	python-win32-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-win32 digest..."


Today's Topics:

   1. win32com and McMillan Installer do not work together
      (Thorsten Henninger)


----------------------------------------------------------------------

Message: 1
Date: Tue, 02 Dec 2003 20:22:16 +0100
From: Thorsten Henninger <henni at brainbot.com>
Subject: [python-win32] win32com and McMillan Installer do not work
	together
To: python-win32 at python.org
Message-ID: <3FCCE668.50108 at brainbot.com>
Content-Type: text/plain; charset=us-ascii; format=flowed

Hi,

I do not get the McMillan Installer work together with the latest
win32all package.
Does anybody have similar problems?

regards,

Thorsten


--
brainbot technologies AG
boppstrasse . 64 . 55118 mainz . germany
fon +49 6131 211639-1 . fax +49 6131 211639-2
http://brainbot.com/  mailto:henni at brainbot.com





------------------------------

_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


End of Python-win32 Digest, Vol 9, Issue 3
******************************************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cheeng, Shu-Chin SC SSI-ISWA2.vcf
Type: text/x-vcard
Size: 365 bytes
Desc: Cheeng, Shu-Chin SC SSI-ISWA2.vcf
Url :
http://mail.python.org/pipermail/python-win32/attachments/20031205/026523b4/Chee
ngShu-ChinSCSSI-ISWA2.vcf

------------------------------

_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


End of Python-win32 Digest, Vol 9, Issue 5
******************************************





More information about the Python-win32 mailing list