win32com.client.Dispatch 打开不需要的独木舟版本

win32com.client.Dispatch opening the undesired canoe version

我的工作站上安装了 2 个 CANoe 版本,我想通过调度打开 CANoe 11(因为我使用了 CANoe 11 中制作的 cfg 文件),但它打开了 CANoe 10。

import time, os, msvcrt
from win32com.client import *
from win32com.client.connect import *

def DoEvents():
    pythoncom.PumpWaitingMessages()
    time.sleep(.1)
def DoEventsUntil(cond):
    while not cond():
        DoEvents()

class CanoeSync(object):
    """Wrapper class for CANoe Application object"""
    Started = False
    Stopped = False
    ConfigPath = ""
    def __init__(self):
        app = DispatchEx('CANoe.Application')    
        app.Configuration.Modified = False
        ver = app.Version
        print('Loaded CANoe version ', 
            ver.major, '.', 
            ver.minor, '.', 
            ver.Build, '...', sep='')
        self.App = app
        self.Measurement = app.Measurement  
        self.Running = lambda : self.Measurement.Running
        self.WaitForStart = lambda: DoEventsUntil(lambda: CanoeSync.Started)
        self.WaitForStop = lambda: DoEventsUntil(lambda: CanoeSync.Stopped)
        WithEvents(self.App.Measurement, CanoeMeasurementEvents)

    def Load(self, cfgPath):
        # current dir must point to the script file
        cfg = os.path.join(os.curdir, cfgPath)
        cfg = os.path.abspath(cfg)
        print('Opening: ', cfg)
        self.ConfigPath = os.path.dirname(cfg)
        self.Configuration = self.App.Configuration
        self.App.Open(cfg)
  
    def Start(self): 
        if not self.Running():
            self.Measurement.Start()
            self.WaitForStart()

    def Stop(self):
        if self.Running():
            self.Measurement.Stop()
            self.WaitForStop()
       
# -----------------------------------------------------------------------------
# main
# -----------------------------------------------------------------------------
app = CanoeSync()

# loads the sample configuration
app.Load('path_to_the_cfg_file')

# start the measurement
app.Start()    

# wait for a keypress to end the program
print("Press any key to exit ...")
while not msvcrt.kbhit():
    DoEvents()

# stops the measurement
app.Stop()

我的问题:有什么方法可以告诉 dispatch 打开哪个 canoe 版本或如何将 canoe 版本 11.0.81 SP3 设置为我的默认 canoe?

我认为首先打开独木舟然后加载 cfg 文件是相关的

我已经试过了:

1.Deleting 独木舟 10 的所有系统和帐户路径,并将它们替换为独木舟 11(之后重新启动电脑)

2.I 试图用 'CANoe.Application.11' 而不是 'CANoe.Application'

在所有这些之后它仍然打开 CANoe 版本 10

谢谢

您必须使用 windows 资源管理器导航至 CANoe 11 安装文件夹 Exec32Exec64

在该文件夹中,您找到一个名为 RegisterComponents.exe

的 EXE-file

执行该文件(具有管理员权限)。

这会将此 CANoe 安装注册为 CANoe-COM-Interface 的服务器。

CANoe 的文档中的主题 技术参考 -> COM 接口 -> 计算机配置中也描述了所有这些内容