472,328 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Calling DLLs from Python [Windows]

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')
Jul 18 '05 #1
2 27939
"Georgy Pruss" <SE************@hotmail.com> 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

# Call the dll one
print "The integer is now: %d" % n.value

# And a few times more:
for i in range(5):
print "The square of the integer is now: %d" % n.value**2
Google didn't help on this.



Brian (remove the sport for mail)
Jul 18 '05 #2

"Brian Elmegaard" <br***@rk-speed-rugby.dk> wrote in message news:un***********@mail.afm.dtu.dk...
"Georgy Pruss" <SE************@hotmail.com> 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.


Sure. The right question is half of the answer :)


Brian (remove the sport for mail)

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Todd Gardner | last post by:
Hello all, Pardon my ignorance here. I would like to talk to someone that has had success in calling ddls in Windows NT/2000/XP. I am...
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python...
by: Brian Elmegaard | last post by:
Hi, I can find a few questions regarding the use of distutils for making non-python windows installers, but none of them really helps. Are there...
by: Dave.NET | last post by:
Hi all, I have the following question and hope the .NET experts here can help me: I developed an application and created many DLLs in VC++,...
by: kim d | last post by:
Hi, I'm looking to call a method of a class which is declared in a dll. I know it's not a simple case of calling dllImport because of the fact that...
by: Shuaib | last post by:
Hi! I have a python script which returns an Integer value. How do I call this script from a C programe, and use the result returned? Thanks...
by: notejam | last post by:
I am trying to get started with a interactive version of Python for windows and need some help. I have played with the tutorial, and now want to...
by: momobear | last post by:
I feel really puzzled about fellowing code, please help me finger out what problem here. import threading class...
by: TheFlyingDutchman | last post by:
I am trying to install Python 2.5 on Windows XP. It installs into the root directory on C:\ instead of C:\Python25 which it shows by default as...
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.