简体   繁体   English

如何克隆OLE / COM注册表项以用于不同的设置

[英]How do I clone a OLE/COM registry entry for use with different settings

I have written a C# program that is to interface with Catia v5.18 via OLE/COM. 我已经编写了一个通过OLE / COM与Catia v5.18交互的C#程序。 It is going to be a common case where the machine the program is ran on will have multiple versions of Catia installed on it. 在运行该程序的计算机上将安装多个版本的Catia,这将是一种常见的情况。 Both older and newer and installed in any funky order. 不论新旧,都可以按照任何时髦的顺序进行安装。 The last one installed gets to put its settings in the registry. 安装的最后一个将其设置放入注册表中。

I'm trying to setup the registry to use a new handle to connect only to a 5.18 CNEXT server. 我正在尝试将注册表设置为使用新句柄仅连接到5.18 CNEXT服务器。 I found the Catia.Application entry in HKEY_CLASSES_ROOT and the CLSID entry. 我在HKEY_CLASSES_ROOT和CLSID条目中找到了Catia.Application条目。 I made copies of these and provided a new UUID for CLSID and came up with the following registry import file: 我制作了这些副本,并为CLSID提供了新的UUID,并提出了以下注册表导入文件:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CATIA.Application.v518]
@="OLE CATIA.Application"

[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
@="{ba3ca493-05fb-4188-a767-f40c03db2672}"

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}]
@="OLE CATIA.Application" "AppID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\LocalServer32]
@="\"C:\\Program Files\\Dassault Systemes\\B18\\intel_a\\code\\bin\\CNEXT.exe\" -env \"CATIA_PLM_Express.V5R18.B18\" -direnv \"C:\\Documents and Settings\\All Users\\Application Data\\DassaultSystemes\\CATEnv\""

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\ProgID]
@="CATIA.Application.v518" 

[HKEY_CLASSES_ROOT\CLSID\{ba3ca493-05fb-4188-a767-f40c03db2672}\VersionIndependentProgID]
@="CATIA.Application" 

I verified that the import worked, but when I run my application I come accross the following error when I try to connect to it. 我验证了导入是否有效,但是当我运行应用程序时,尝试连接到该应用程序时遇到以下错误。

System.Runtime.InteropServices.C OMException (0x80080005): Retrieving the COM class factory for component with CLSID {BA3CA493-05FB-4 188-A767-F40C03DB2672} failed due to the following error: 80080005 Server execution failed (Exceptio n from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)

I'm able to run this program fine on the normal installs using "CATIA.Application" and "CATIA.Application.1", but here is the code I use to connect to the Application if it matters: 我可以使用“ CATIA.Application”和“ CATIA.Application.1”在常规安装上很好地运行此程序,但是如果需要的话,这是我用来连接到应用程序的代码:

public CatiaApplication() {

  Type catia_program_id = Type.GetTypeFromProgID( "CATIA.Application.v518" );

  try {
    this._instance = (Application)Activator.CreateInstance( catia_program_id );
  }
  catch( Exception ex ) {
    throw new ApplicationException( "Failed to access Catia Application: " + ex.ToString());
  }
}

Anybody have any ideas? 有人有什么想法吗? I haven't tried to reboot the box but so far it looks like the changes take effect immediately. 我没有尝试过重启盒子,但是到目前为止,更改似乎立即生效。

Shouldn't it be this instead? 不应该是这个吗?

[HKEY_CLASSES_ROOT\CATIA.Application.v518]
"CLSID"="{ba3ca493-05fb-4188-a767-f40c03db2672}"

where you wrote it: 在哪里写的:

[HKEY_CLASSES_ROOT\CATIA.Application.v518\CLSID]
@="{ba3ca493-05fb-4188-a767-f40c03db2672}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM