ctypes and twain_32.dll

Discussion in 'Python' started by Patrick Vrijlandt, Apr 30, 2011.

  1. Hi,

    I'm trying to access TWAIN from python 3.2 on Vista, using ctypes. I'm
    stuck at line 2:

    PythonWin 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit
    (Intel)] on win32.
    >>> from ctypes import *
    >>> windll.twain_32

    Traceback (most recent call last):
    File "<interactive input>", line 1, in <module>
    File "C:\Python32\lib\ctypes\__init__.py", line 410, in __getattr__
    dll = self._dlltype(name)
    File "C:\Python32\lib\ctypes\__init__.py", line 340, in __init__
    self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 1114] Een initialisatieroutine van de dynamic
    link library (DLL-bestand) is mislukt

    [Yes, I'm Dutch. It says: An initialisation procedure of the DLL has
    failed]

    This is from a .NET / TWAIN example on http://www.codeproject.com:

    As the TWAIN API is exposed by the Windows DLL, twain_32.dll, we have
    to use the .NET DllImport mechanism for interop with legacy code. This
    DLL has the central DSM_Entry(), ordinal #1 function exported as the
    entry point to TWAIN. This call has numerous parameters, and the last
    one is of variable type! It was found to be best if we declare
    multiple variants of the call like:

    [DllImport("twain_32.dll", EntryPoint="#1")]
    private static extern TwRC DSMparent(
    [In, Out] TwIdentity origin,
    IntPtr zeroptr,
    TwDG dg, TwDAT dat, TwMSG msg,
    ref IntPtr refptr );

    I suspect that initialisation may fail because of missing arguments,
    but I see no way of sending any arguments. Also, contrary to the .NET
    example, I cannot express that the DLL entrypoint has ordinal 1. Of
    course, I may be totally wrong!

    I'm hoping for your suggestions!

    TIA,

    Patrick
     
    Patrick Vrijlandt, Apr 30, 2011
    #1
    1. Advertising

  2. Hi!

    On my system, thera are not "twain32.dll" or "twain_32.dll", but "twain.dll"

    @+
    --
    Michel Claveau
     
    Michel Claveau - MVP, May 2, 2011
    #2
    1. Advertising

  3. On 2 mei, 20:56, "Michel Claveau -
    MVP"<> wrote:
    > Hi!
    >
    > On my system, thera are not "twain32.dll" or "twain_32.dll", but "twain.dll"
    >
    > @+
    > --
    > Michel Claveau


    Hi,

    I have both. They are correctly installed and working. ctypes gives a
    different response if it cannot find the requested DLL.

    Patrick
     
    Patrick Vrijlandt, May 3, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    8,991
  2. Henk Punt
    Replies:
    0
    Views:
    424
    Henk Punt
    Jul 23, 2004
  3. Uri Nix

    ctypes and DLL exceptions

    Uri Nix, Feb 21, 2007, in forum: Python
    Replies:
    0
    Views:
    233
    Uri Nix
    Feb 21, 2007
  4. Replies:
    0
    Views:
    535
  5. H. Simpson
    Replies:
    4
    Views:
    342
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page