How to debug a COM-Type dll in python implemented with python package pywin32

0

I'm trying to remote control a CCD camera from Horiba (Symphony) and got an old SDK. The SDK is simply a dll with a pdf manual for the functions included. The dll was created for C#, but all out software is running on python. The the dll is a COM-type and 32bit. I registered the dll in windows with regsvr32 "C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Detectors\JYMCD\JYCCD.dll" and created a 32bit conda enviroment where I installed pywin32. Then I followed this discription. I created a pyhton file with win32com:

import sys
from win32com.client import makepy

outputFile = r"c:\projectFolder\JYCCD_test.py"
comTypeLibraryOrDLL = r"C:\Program Files (x86)\Jobin Yvon\Common\JY Components\Detectors\JYMCD\JYCCD.dll"
sys.argv = ["makepy", "-o", outputFile, comTypeLibraryOrDLL]

makepy.main ()

In the output file all functions described in the manual are there. There are 3 clases:

class IJYCCDReqd(DispatchBaseClass):
    'IJYCCDRequired Interface'
    CLSID = IID('{0D684CA0-9552-4B26-B420-2BEE5BD4F1A0}')
    coclass_clsid = IID('{4D7AAEFC-19F9-49B7-A5BB-814933694FD3}')

class _IJYDeviceReqdEvents:
    '_IJYDeviceReqdEvents Interface'
    CLSID = CLSID_Sink = IID('{A2C81A78-CA13-4A39-8FCB-CD51BD4E9376}')
    coclass_clsid = IID('{4D7AAEFC-19F9-49B7-A5BB-814933694FD3}')
    _public_methods_ = [] # For COM Server support
    _dispid_to_func_ = {
                1 : "OnInitialize",
                2 : "OnOperationStatus",
                3 : "OnUpdate",
                4 : "OnCriticalError",
        }

class JYMCD(CoClassBaseClass): # A CoClass
    # JYMCD Class
    CLSID = IID('{4D7AAEFC-19F9-49B7-A5BB-814933694FD3}')
    coclass_sources = [
        _IJYDeviceReqdEvents,
    ]
    default_source = _IJYDeviceReqdEvents
    coclass_interfaces = [
        IJYCCDReqd,
    ]
    default_interface = IJYCCDReqd

I created a new python file where I imported this file and want to initialize the class:

import win32com.client
import JYCCD_test

CCD: JYCCD_test.IJYCCDReqd = win32com.client.Dispatch(JYCCD_test.JYMCD.CLSID)

CCD.OpenCommunications()

Pycharm is recognizing CCD and suggest also all functions in the dll, I just chose OpenCommunications(). There is no error and the programm finishes with Process finished with exit code -1073740771 (0xC000041D). I tried to debug, but python is running without error. I traced down the issue to win32com.client.Dispatch(JYCCD_test.JYMCD.CLSID). Am I doing somthing wrong, or is something not initialized correctly. There is also a USB Dongle, without the SDK should not work. Do I have to "install" or "register" this some where first? I don't know how to debug the exit code from python. We have a more or less working C# code, but I have no expierience with C# and there the dll is loaded in 2 lines (as I understand it).

python
c#
debugging
dll
com
asked on Stack Overflow Aug 4, 2020 by rubi

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0