Re: ctypes and twain_32.dll [SEC=PERSONAL]
"Andrew MacIntyre" <[email protected]> Tue, 3 May 2011 08:57:31 +0000
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <A1E4E9D08D14924498E135FB4441EE8D01C4423D@act01exmbx01vp.internal.govt> |
[apologies for top posting] Sorry, can't help with the main part of your problem, but calling functions by ordinal is definitely supported (& documented) by using index notation: windll.twain_32[1] -------------------------> "These thoughts are mine alone!" <--------- Andrew MacIntyre Operations Branch tel: +61 2 6219 5356 Communications Infrastructure Division fax: +61 2 6253 3277 Australian Communications & Media Authority email: [email protected]<mailto:[email protected]> http://www.acma.gov.au/ From: Patrick Vrijlandt [mailto:[email protected]] Sent: Tuesday, 3 May 2011 4:08 PM To: [email protected] Subject: [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 NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. ------------------------------------------------------------------------------ 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