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

问题描述

我在工作站上安装了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()

我的问题:有什么方法可以告诉调度员打开哪个独木舟版本,或者如何将11.0.81 SP3版本的独木舟设置为我的认独木舟?

我认为首先打开独木舟然后加载cfg文件是很重要的

我已经尝试过:

1。删除独木舟10的所有系统和帐户路径,并将其替换为独木舟11(此后重新启动pc)

2。我尝试放置“ CANoe.Application.11”而不是“ CANoe.Application”

毕竟,它仍然可以打开CANoe版本10

谢谢

解决方法

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

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

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

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

CANoe文档中的主题技术参考-> COM接口-> 计算机配置

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...