Help accessing COM .dll from Python
First time post - be gentle with me :-) I am trying to write a Python script to access a scanning device. I have an SDK for the scanner but the documentation is a bit limited and the supplier doesn't support Python (but Python is the best option for me in the current circumstances). The SDK revolves around a .dll file that is described as a 'COM Object' but the text also implies that it can be accessed directly - "If you dont use the COM interface in your application and use the SDK files directly like in VC++ then you dont need to install these files on the destination computer". If I look inside the .dll (thanks PE Explorer!), I see DllCanUnload, DllGetClassObject, DllRegisterServer and DllUnregisterServer in the 'Export' view. If I look at the 'Import' view, I can see the names of a bunch of .dll files and the names of the functions/methods I want to call. So I concluded that DllGetClassObject would be my friend. However, I've read various tutorials on using .dll and COM (ctypes, comtypes, and the Python documentation) and I've ended up more confused than when I started. I expected to be using COM but all the examples seem to revolve around automating excel or outlook. I'd be really grateful for some hints on what direction I should be headed and a pointer to a relevant tutorial. Simmo -- http://mail.python.org/mailman/listinfo/python-list
Re: Help accessing COM .dll from Python
Steve Simmons square.st...@gmail.com wrote: html head meta http-equiv=content-type content=text/html; charset=ISO-8859-1 /head body text=#00 bgcolor=#FF font size=-1font face=Bitstream Vera SansFirst time post - be gentle wifont size=-1th me :-)br br /fontI am trying to write a Python font size=-1script to access a scanning dfont size=-1evice.nbsp; font size=-1I have an SDK for tfont size=-1he/font font size=-1scanner but the documentation is a font size=-1bit limited and the supplier doesn't support Python (but font size=-1font size=-1Python is the best option for me font size=-1in the current circumstances)./font/fontnbsp;/font/font/font /font/font br br The SDK revolves around a .dll fifont size=-1le that font size=-1is described as a 'COM Obfont size=-1ject' but the text also implies that it can be acfont size=-1cessed directly - If you don#8217;t use the COM interface in your application and use the SDK files directly like in VC++ then you don#8217;t need to install these files on the destination computer.nbsp; If I look inside the .dfont size=-1ll (thanks PEfont size=-1 Explorer!), I see DllCanUnload, DllGetClassObject, DllRegisterServer and DllUnregisterServer in the 'Export' view.nbsp; If I look at font size=-1the 'Import' view, I can see the names of a buncfont size=-1h of font size=-1.dll files and /font/fontthe names of the font size=-1functions/font/methods I want to call.nbsp; So I concluded thatnbsp; /font/font/font/font/font/font/font/font /font/fontfont size=-1font face=Bitstream Vera Sansfont size=-1font size=-1font size=-1font size=-1font size=-1font size=-1font size=-1font size=-1font size=-1font face=Bitstream Vera Sansfont size=-1font size=-1font size=-1font size=-1font size=-1font size=-1font size=-1DllGetClassObject font size=-1would be my friend./font/font/font/font/font/fon t/font/font/font/font/font /font/fontbr br font size=-1However, I've font size=-1read various tutorials on using .dll and COM (ctypes, comtypes, and the Python documentation) and I've ended up font size=-1more confused than when I started.nbsp; font size=-1I expected to be using COM but all the examples seem to revolve around automating excel or outfont size=-1look.br br font size=-1I'd be really grateful for some hints on what direction Ifont size=-1 should be headfont size=-1ed and a pointer to a relevant tutorial./font/font/font/font /font/font/font/fontbr br font size=-1Simmo/fontbr /font/font/font/font/font/font/font /body /html A newsreader is not an HTML reader (aka web browser). Please post your question in plain text. Best regards, Günther -- http://mail.python.org/mailman/listinfo/python-list
Re: Help accessing COM .dll from Python
Quoting his entire text for the benefit of Mr Dietrich, who is apparently having trouble reading it. (He's right though, plain text is a lot easier to work with.) On Sat, Dec 1, 2012 at 8:51 PM, Steve Simmons square.st...@gmail.com wrote: First time post - be gentle with me :-) I am trying to write a Python script to access a scanning device. I have an SDK for the scanner but the documentation is a bit limited and the supplier doesn't support Python (but Python is the best option for me in the current circumstances). The SDK revolves around a .dll file that is described as a 'COM Object' but the text also implies that it can be accessed directly - If you don’t use the COM interface in your application and use the SDK files directly like in VC++ then you don’t need to install these files on the destination computer. If I look inside the .dll (thanks PE Explorer!), I see DllCanUnload, DllGetClassObject, DllRegisterServer and DllUnregisterServer in the 'Export' view. If I look at the 'Import' view, I can see the names of a bunch of .dll files and the names of the functions/methods I want to call. So I concluded that DllGetClassObject would be my friend. However, I've read various tutorials on using .dll and COM (ctypes, comtypes, and the Python documentation) and I've ended up more confused than when I started. I expected to be using COM but all the examples seem to revolve around automating excel or outlook. I'd be really grateful for some hints on what direction I should be headed and a pointer to a relevant tutorial. Simmo Yeah, ctypes isn't all that easy to work with I'm afraid. Ultimately, your problem is with your scanner's SDK; if it's poorly documented, it's not going to be any easier working from Python than it would be from C. I would advise following their non-COM instructions as closely as you can, and seeing where that leads you. If their docs are online, post us a link; it's possible someone here may be familiar with it, or at very least be able to help you with the translation to Python. Good luck! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Help accessing COM .dll from Python
Gunther - Sorry about that, hoping this response comes through as plain text. Chris - Thanks for the translation and the response. Unfortunately, I don't speak 'C', and I think the learning curve for Python + COM should be slightly less steep. The scanner is supplied by Card Scanning Solutions (CSSN in USA) and their docs are accessible from http://www.cardscanning.com/developers.php. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help accessing COM .dll from Python
On Sat, Dec 01, 2012 at 12:47:57PM +, Steve Simmons wrote: Gunther - Sorry about that, hoping this response comes through as plain text. Chris - Thanks for the translation and the response. Unfortunately, I don't speak 'C', and I think the learning curve for Python + COM should be slightly less steep. i've had some some expirience using COM from python with pywin32, which works reasonably well if your interfaces is documented. as for examples beeing excel centric: it does not really matter, you just have to look the real interface you want to use in the documentation of your libary. there are however some pitfalls, espesially with arguments passed by reference: there not the parameter will be modified but you will have a tuple as a return value. albert signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Help accessing COM .dll from Python
Hi, Am 01.12.2012 10:51, schrieb Steve Simmons: First time post - be gentle with me :-) I am trying to write a Python script to access a scanning device. I have an SDK for the scanner but the documentation is a bit limited and the supplier doesn't support Python (but Python is the best option for me in the current circumstances). From a quick view it seems the documentation is excellent. There are tons of examples (even Java so you could use jython), API documents and the SDK. The VC SDK.pdf from the API documents zip explains what functions are there and how to call them. I have no idea why you used PEExplorer, are you using a device not covered by Slib.dll? Anyway, I suggest you forget about COM and try to load Slib.dll via ctypes http://docs.python.org/2/library/ctypes.html and call some functions documented in VC SDK.pdf and see what happens. The defines for return codes used in the documentation are here http://www.id-reader.com/Support/Sample_Codes/Visual_C_Plus_Plus/header_lib.rar in SlibErrDef.h and probably others... cheers Paul The SDK revolves around a .dll file that is described as a 'COM Object' but the text also implies that it can be accessed directly - If you don’t use the COM interface in your application and use the SDK files directly like in VC++ then you don’t need to install these files on the destination computer. If I look inside the .dll (thanks PEExplorer!), I see DllCanUnload, DllGetClassObject, DllRegisterServer and DllUnregisterServer in the 'Export' view. If I look at the 'Import' view, I can see the names of a bunch of .dll files and the names of the functions/methods I want to call. So I concluded that DllGetClassObject would be my friend. However, I've read various tutorials on using .dll and COM (ctypes, comtypes, and the Python documentation) and I've ended up more confused than when I started. I expected to be using COM but all the examples seem to revolve around automating excel or outlook. I'd be really grateful for some hints on what direction Ishould be headed and a pointer to a relevant tutorial. Simmo -- http://mail.python.org/mailman/listinfo/python-list