I am trying to work with a windows dll from the odoo 9 code. The code in the python class is:
import win32com.client
import pythoncom
Pythoncom.CoInitialize ()
Zk = win32com.client.Dispatch ('zkemkeeper.ZKEM.1')
When I run it on Windows 8 (64 bit) it works without problems, but when I run it on Windows 10 (64 bit) as a service, I get the following error in the log file:
File "C: \ Python27 \ lib \ site-packages \ win32com \ client \ dynamic.py", line 85, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance (IDispatch, None, clsctx, pythoncom.IID_IDispatch)
Com_error: (-2147221164, 'Class not registered', None, None)
I checked Regedit; the dll is registered.
When I install Python 32 bit on that same PC, and run the code from the console directly, it gives me the same error. However, I installed Python 64 bit and ran the same code, and it worked fine.
Could anyone tell me how I could fix this error with odoo as a service? Is there any way to point to the 64-bit python I installed on the PC and not the internal one?
Try to add context with
clsctx=pythoncom.CLSCTX_LOCAL_SERVER
to the args passed to Dispatch.