python - dll access (ctypes or swig)

Daniel Watrous dwmaillist at gmail.com
Wed Apr 18 10:38:51 EDT 2007


thank you for the responses and the links.  I will give these ideas a
try this week and post again if I have more questions.  Thanks again
for being so helpful!

Daniel

On 4/17/07, Cameron Laird <claird at lairds.us> wrote:
> In article <mailman.6640.1176846203.32031.python-list at python.org>,
> Larry Bates  <larry.bates at websafe.com> wrote:
> >Daniel Watrous wrote:
> >> Hello,
> >>
> >> I am interested in using python to script access to some hardware for
> >> which there are existing drivers in the form of DLLs.  The DLLs each
> >> have four exported functions and a host of COM Properties and COM
> >> Methods.  The four exported functions are as follows:
> >> DllCanUnloadNow
> >> DllGetClassObject
> >> DllRegisterServer
> >> DllUnregisterServer
> >>
> >> The COM methods and properties all begin with I, followed by a unique name.
> >>
> >> I am able to load the DLL using ctypes and it can access the exported
> >> functions, but I'm not sure how to access the COM methods and
> >> properties.  I have read that ctypes once had support for COM but that
> >> it has since been separated into its own project.  I couldn't find any
> >> information about how these work together.
> >>
> >> All help is appreciated.  THANKS in advance...
> >>
> >> Daniel
> >
> >I recently learned that you can ship COM as either an .EXE or a .DLL (nobody
> >has yet let me know why).  You don't have a traditional .DLL that you would
> >use ctypes to call methods in, you have a COM .DLL.  COM methods need to be
> >access with Win32com
> >
> >obj=win32com.client.Dispatch("typelib name").
> >
> >You need to find out the COM dispatch typelib name and make sure the DLL is
> >registered (regsvr32 your.dll).
> >
> >-Larry
>
> Is this--adroit use of Win32com with special-purpose DLLs--written
> up anywhere?  Doing this with unusual hardware that turns up in the
> real world is ENTIRELY more satisfying than trying to wrangle the
> Visual C bindings that vendors usually push, but, apart from Mark
> and Andy's book, now over seven years old, I know of no appropri-
> ately ambitious tutorial in the subject.
>
> Daniel, do you have what you need to make progress?  Have you seen
> <URL: http://www.oreilly.com/catalog/pythonwin32/ >?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list