Re: Accessing a dll from Python

2005-10-21 Thread Simon Brunning
On 21/10/05, Grant Edwards <[EMAIL PROTECTED]> wrote:
> Sorry, I've no clue about anything VB-related unless it's
> Victoria Bitter.

+1 QOTW.

--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-21 Thread Grant Edwards
On 2005-10-20, dcrespo <[EMAIL PROTECTED]> 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.coman ENRICHED BUN!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-20 Thread Tim Roberts
"dcrespo" <[EMAIL PROTECTED]> 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, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-20 Thread mku
I used ctypes. It works really fine with DLLs.
have a lool at http://starship.python.net/crew/theller/ctypes
Martin

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-20 Thread Larry Bates
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/Cookbook/Python/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
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing a dll from Python

2005-10-20 Thread Richie Hindle

[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
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list