ctypes and twain_32.dll

P

Patrick Vrijlandt

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.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
 
M

Michel Claveau - MVP

Hi!

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

@+
 
P

Patrick Vrijlandt

Hi!

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

@+

Hi,

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

Patrick
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top