4

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?

Sagar
  • 9,456
  • 6
  • 54
  • 96
Dayana
  • 1,500
  • 1
  • 16
  • 29

2 Answers2

3

Try to add context with

clsctx=pythoncom.CLSCTX_LOCAL_SERVER 

to the args passed to Dispatch.

  • 2
    It worked perfectly, thanks! I wrote: `Zk = win32com.client.Dispatch ('zkemkeeper.ZKEM.1', clsctx=pythoncom.CLSCTX_LOCAL_SERVER)` – Dayana Aug 23 '17 at 20:58
0

t = win32com.client.Dispatch("TDApiOle80.TDConnection")

It is not working for this .

tdc = win32com.client.Dispatch("TDApiOle80.TDConnection",clsctx=pythoncom.CLSCTX_LOCAL_SERVER)

Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)

codeLover
  • 2,571
  • 1
  • 11
  • 27