473,498 Members | 1,528 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing a dll from Python

Hi to all,

Can someone give me lights on how can I deal with dlls from python?

My main purpose is to get access to a Unitech PT600 Bar Code system. I
have the dll that works fine through Visual Basic. But I'm migrating to
Python, so I need a way to use the same dll, or a C library.

I tried to access a dll created by myself on Visual Basic. The dll just
have one function. It works perfect when using it on a VB project just
including it in the references configuration. But I can't access it
from python. I tried the ctypes module.

Thank you

Daniel

Oct 20 '05 #1
6 8281

[Daniel]
I tried the ctypes module.


ctypes is the right way to do it. You need to post your code and whatever
errors you received. Here's an example of using ctypes to call a DLL:
from ctypes import *
windll.user32.MessageBoxA(None, "Hello world", "ctypes", 0);


You use "windll" for stdcall functions (eg. the Windows API) and "cdll" for
cdecl functions. I don't know which one VB defaults to. If you get it
wrong, ctypes will give you an error talking about using the "wrong calling
convention".

--
Richie Hindle
ri****@entrian.com
Oct 20 '05 #2
If you want you can also take a look at something I wrote a while
ago (before ctypes was really well known). It has worked for me
with .DLLS form Castelle and Expervision that both have extensive
APIs. It is located here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/146847

Larry Bates

dcrespo wrote:
Hi to all,

Can someone give me lights on how can I deal with dlls from python?

My main purpose is to get access to a Unitech PT600 Bar Code system. I
have the dll that works fine through Visual Basic. But I'm migrating to
Python, so I need a way to use the same dll, or a C library.

I tried to access a dll created by myself on Visual Basic. The dll just
have one function. It works perfect when using it on a VB project just
including it in the references configuration. But I can't access it
from python. I tried the ctypes module.

Thank you

Daniel

Oct 20 '05 #3
mku
I used ctypes. It works really fine with DLLs.
have a lool at http://starship.python.net/crew/theller/ctypes
Martin

Oct 20 '05 #4
"dcrespo" <dc*****@gmail.com> wrote:

Can someone give me lights on how can I deal with dlls from python?

My main purpose is to get access to a Unitech PT600 Bar Code system. I
have the dll that works fine through Visual Basic. But I'm migrating to
Python, so I need a way to use the same dll, or a C library.

I tried to access a dll created by myself on Visual Basic. The dll just
have one function. It works perfect when using it on a VB project just
including it in the references configuration. But I can't access it
from python. I tried the ctypes module.


Are you talking about VB6 or VB.NET? If you had to add a reference, then
it is either a COM interface or a managed code class. DLLs don't get in
through references -- they use the Declare statement.

COM interfaces are pretty easy to call in Python. Calling managed code is
almost impossible right now.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 21 '05 #5
On 2005-10-20, dcrespo <dc*****@gmail.com> wrote:
Can someone give me lights on how can I deal with dlls from python?
Use the ctypes module.
My main purpose is to get access to a Unitech PT600 Bar Code system. I
have the dll that works fine through Visual Basic. But I'm migrating to
Python, so I need a way to use the same dll, or a C library.
ctypes can call dll functions using either C or Pascal calling
conventsions.
I tried to access a dll created by myself on Visual Basic. The
dll just have one function. It works perfect when using it on
a VB project just including it in the references
configuration. But I can't access it from python. I tried the
ctypes module.


ctypes has always worked for me.

Sorry, I've no clue about anything VB-related unless it's
Victoria Bitter.

--
Grant Edwards grante Yow! I have a VISION! It's
at a RANCID double-FISHWICH on
visi.com an ENRICHED BUN!!
Oct 21 '05 #6
On 21/10/05, Grant Edwards <gr****@visi.com> wrote:
Sorry, I've no clue about anything VB-related unless it's
Victoria Bitter.


+1 QOTW.

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Oct 21 '05 #7

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

Similar topics

7
10266
by: Fazer | last post by:
Hello, I have a MP3 and I want to access the songs in them. I was wondering if Python could help me do that. I understand that this can be done using Linux by mountig it as a file system, but...
4
4187
by: Mickel Grönroos | last post by:
Hi! I'm fiddling with Python for Windows (normally using Linux) and as a part of that I want to try to make a simple word frequency list generator to be used in conjunction with Microsoft Word....
0
1224
by: paul cannon | last post by:
Having poked around a little bit, I found there doesn't appear to be any way to get at the contents of a cell object from Python. It's not the sort of thing that one needs to be doing very...
13
14696
by: Joseph Garvin | last post by:
When I first came to Python I did a lot of C style loops like this: for i in range(len(myarray)): print myarray Obviously the more pythonic way is: for i in my array: print i
14
3862
by: James Thiele | last post by:
I'd like to access the name of a function from inside the function. My first idea didn't work. >>> def foo(): .... print func_name .... >>> foo() Traceback (most recent call last): File...
0
1493
by: Doug Caldwell | last post by:
Hi! ** Accessing the USGS Web Service Using Python ** I am trying to access the US Geological Survey's gazetteer SOAP web service using Python to find the locations of all the places with the...
0
1028
by: Phoe6 | last post by:
Hi all, I have to uninstall an application and I don't find the uninstaller, the option available to me is to access Add/Remove Programs, select the application and remove from there. I am...
3
2096
by: sam | last post by:
hello all, i am currently in the process of planning a piece of software to model polymerisation kinetics, and intend to use python for all the high-level stuff. the number-crunching is...
2
1250
by: kyosohma | last post by:
Hi All, I need to access a Microsoft SQL database View. Is there a way to do this with Python? I have done a fair share of "googling" and found nothing on accessing Views, just executing SQL,...
10
1580
by: Chris | last post by:
Hi, I'd like to be able to access an attribute of a particular Python object as fast as possible from some C code. I wondered if using __slots__ to store the attribute would allow me to do...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.