Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Calling DLLs from Python [Windows]

Reply
Thread Tools

Calling DLLs from Python [Windows]

 
 
Georgy Pruss
Guest
Posts: n/a
 
      10-08-2003
Hi all,

How can I call a function which is in a Windows DLL? For example,

import win32api
lib_hnd = win32api.LoadLibrary( "user32.dll" )
if lib_hnd:
fn_addr = win32api.GetProcAddress( lib_hnd, "MessageBeep" ) # returns int(2010532466)
if fn_addr:
# Here I'd like to call fn_addr. In C it would be plain fn_addr()
win32api.FreeLibrary( lib_hnd )

Google didn't help on this.

Thank you,
Georgy Pruss
E^mail: 'ZDAwMTEyMHQwMzMwQGhvdG1haWwuY29t\n'.decode('base6 4')


 
Reply With Quote
 
 
 
 
Brian Elmegaard
Guest
Posts: n/a
 
      10-08-2003
"Georgy Pruss" <(E-Mail Removed)> writes:

> How can I call a function which is in a Windows DLL? For example,


ctypes is your friend
from ctypes import *

If you have t.dll exporting INCREMENT

# load dll
inc = windll.LoadLibrary("t.dll")

# Initiate c-variable for the dll
n=c_int(1)

# Call the dll one
inc.INCREMENT(byref(n))
print "The integer is now: %d" % n.value

# And a few times more:
for i in range(5):
inc.INCREMENT(byref(n))
print "The square of the integer is now: %d" % n.value**2

> Google didn't help on this.


???????

http://groups.google.com/groups?hl=e...=Google+Search



--
Brian (remove the sport for mail)
http://www.et.dtu.dk/staff/be
 
Reply With Quote
 
 
 
 
Georgy Pruss
Guest
Posts: n/a
 
      10-08-2003

"Brian Elmegaard" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> "Georgy Pruss" <(E-Mail Removed)> writes:
>
> > How can I call a function which is in a Windows DLL? For example,

>
> ctypes is your friend


Thank you!

>
> > Google didn't help on this.

>
> ???????
>
> http://groups.google.com/groups?hl=e...=Google+Search
>


Sure. The right question is half of the answer
Thanks!

Georgy.

>
>
> --
> Brian (remove the sport for mail)
> http://www.et.dtu.dk/staff/be



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
are DLLs needed to run glade interfaces in python with Windows? Fernando Python 1 04-13-2005 07:07 PM
python and win32 dlls fgrillo64 Python 1 08-09-2004 01:19 PM
Do .Net Client Applications require MSSoap dlls for calling WebServices? Jack Wright ASP .Net Web Services 3 07-30-2004 11:19 AM
Fortran-compiled DLLs in Python byte biscuit Python 7 06-01-2004 11:57 AM
Calling dlls with Calldll/WinDll or Ctypes or... Todd Gardner Python 3 01-14-2004 12:57 AM



Advertisments