0

I am trying to interact with a provided DLL. It is already registerd.

With python -m win32com.client.makepy -i I generated a python file to interact with the DLL.

But when I try to use the provided functionality with

import provided_file
api = provided_file.IGLobalVision8API()

I get the following error:

Traceback (most recent call last):
  File "C:\Users\-----\main.py", line 23, in <module>
    main()
  File "C:\Users\-----\main.py", line 15, in main
    api = provided_file.IGlobalVision8API()
  File "C:\Users\-----\venv\lib\site-packages\win32com\client\__init__.py", line 514, in __init__
    oobj = pythoncom.new(self.CLSID)
pywintypes.com_error: (-2147221164, 'Klasse nicht registriert', None, None)

Similar thing happens when I try to use

api = client.Dispatch("{0A67E301-3ECB-47BE-BBA9-DC67FF219358}")

where I get the following error:

Traceback (most recent call last):
  File "C:\Users\-----\venv\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Vorgang nicht verfügbar.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\-----\main.py", line 23, in <module>
    main()
  File "C:\Users\-----\main.py", line 14, in main
    api = client.Dispatch("{0A67E301-3ECB-47BE-BBA9-DC67FF219358}")
  File "C:\Users\-----\venv\lib\site-packages\win32com\client\__init__.py", line 117, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
  File "C:\Users\-----\venv\lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Users\-----\venv\lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(
pywintypes.com_error: (-2147221164, 'Klasse nicht registriert', None, None)

Can anyone help me figure out why I can't interact with my DLL?

Moosi312
  • 31
  • 1
  • 6
  • 1
    Contrary to your belief, your dll is probably not properly registered: How to solve COM Exception Class not registered (Exception from HRESULT: 0x80040154 (REGDB\_E\_CLASSNOTREG))?(https://stackoverflow.com/questions/1496214/how-to-solve-com-exception-class-not-registered-exception-from-hresult-0x80040) – Simon Mourier Aug 30 '22 at 07:30

1 Answers1

0

If DLL is properly registered, a common problem could be, your DLL is 32 bit, but your main application (python?) is 64 bit. Try using python 32 bit.

Nikolay
  • 10,752
  • 2
  • 23
  • 51