Newbie Q: How to call unmodified VB DLL from Python

radbit at my-deja.com radbit at my-deja.com
Mon Jun 21 02:10:01 CEST 1999


In article <3769bcd1.54492213 at news.earthlink.net>,
  lull at acm.org (John Lull) wrote:
> As a first Python project, I'd like to use Python (or JPython) to
> automate some hardware testing under Win95/98/NT.  The hardware in
> question is run by a DLL written in VB, and to which I do not have
> source.
>
> "Extending & Embedding the Python interpreter", ch. 3, has
> instructions for building a DLL which will work, but assumes you're
> working in VC++ and have the source.
>
> If anyone could point me toward instructions on how to make this work,
> I'd be grateful.
>
> Thanks.
>
> Regards,
> John
>
>

Hi

since VB has only been able to do in-process OLE (Com) Dlls since VB4.0
I take it that this DLL exposes its methods via COM. In which case it
should be a snip to talk to it via Marc Hammond's Pythonwin COM
support. Find out what it's programmatic id is (progid) from
Pythonwin's COM browser or MS VC++'s COM Viewer. Once you know what
progid it has you can do:

>>> from win32com.client import Dispatch
>>> vbObj=Dispatch('progid')

or you can also look at the methods it exposes via Pythonwin's Com
browser.

If the Dll is not written in VB then you'll probably need Sam Rushing's
CallDll package which lets you invoke the LoadLibray,GetProcAddress, etc
functions.

Hope this helps

--
Florent Heyworth


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list