Re: ctypes and twain_32.dll
"Patrick Vrijlandt" <[email protected]> Fri, 6 May 2011 10:10:14 +0200
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <BA15E7E3B8D64E4582D6546D4AB2AF33@ViaWinXP> |
It turns out, that the code does work when run with Administrator rights. Patrick _____ Van: Patrick Vrijlandt [mailto:[email protected]] Verzonden: dinsdag 3 mei 2011 8:08 Aan: [email protected] Onderwerp: [ctypes-users] ctypes and twain_32.dll 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/> 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 ------------------------------------------------------------------------------ WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users