Mailing List Archive

Newbie Q: How to call unmodified VB DLL from Python
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
Newbie Q: How to call unmodified VB DLL from Python [ In reply to ]
In article <3769bcd1.54492213@news.earthlink.net>,
lull@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.
Newbie Q: How to call unmodified VB DLL from Python [ In reply to ]
lull@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.
You need to use Sam Rushing's calldll/windll package at
www.nightmare.com. This lets you load and call functions in DLLs
dynamically (i.e. without needing a C compiler). It also provides
python types to emulate C strings and arbitrary memory buffers, so can
call anything.

Needless to say, it is also possible to crash stuff if you get the
arguments wrong, but once set up it works beautifully. I have been
using it in production round the clock for months now...

Regards,

Andy
Newbie Q: How to call unmodified VB DLL from Python [ In reply to ]
In the waning years of the 20th century, radbit@my-deja.com wrote
(with possible deletions):

> 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')

This should get me started.

Thanks.

Regards,
John