使用 AutoCAD 注册表项和 Inno Setup 安装 AutoCAD vlx 文件

Installing AutoCAD vlx files with AutoCAD registry keys and Inno Setup

我有一些 vlx 文件要添加到我的 AutoCAD 文件夹中。我想使用 Inno Setup 制作安装包,它将在 post 安装我的 vlx 文件 install.I 获得了 AutoCAD 2014 的注册表项。

HKEY_LOCAL_MACHINE\Software\Autodesk\AutoCAD\R19.1\ACAD-D001:409

请告诉我以上案例的 inno 设置脚本。

我发现这个 article 其中指出:

Below is a Inno Setup/Pascal code example of how to loop through AutoCAD versions and create the relevant LspLoad registry entries for an imaginary application called "MyCADApp". It is purely to demonstrate the mechanism. It is stripped down to just do 64bit ACAD on 64bit Windows to demonstrate the principle.

Once you've got a handle on the pascal scripting, it should be relatively straight forward to modify/expand it to add tests for 32bit CAD on 64bit Windows and 32bit CAD on 32bit Windows and of course do similar for Bricscad. All the additional functions you may require eg "IsWin64" can be found in the "Support Function Reference" in the Inno Setup Help files.

procedure AddACADRegKey (Release: String); {eg 'R19.0 for ACAD 2013'}
var
  RunTimeNum: String; {eg '19'}
  AllProductID: TArrayOfString;
  ProductID: String; {eg 'ACAD-9001:409'}
  KeyPathShort: String;{eg 'SOFTWARE\Autodesk\AutoCAD\'}
  KeyPathLong: String; {eg 'SOFTWARE\Autodesk\AutoCAD\R18.1\ACAD-9001:409\Applications\MyCADApp'}
  KeyStringShort: String; {eg c:\Program Files\MyCADApp\LspLoad.'}
  KeyStringLong: String; {eg 'c:\Program Files\MyCADApp\LspLoad.19.x64.arx'}   
  I: Integer;
begin
  RunTimeNum := Copy (Release, 2, 2);
  KeyStringShort := ExpandConstant('{pf}\MyCADApp\LspLoad.');
  KeyPathShort := 'SOFTWARE\Autodesk\AutoCAD\';
  if RegGetSubkeyNames(HKLM64, KeyPathShort + Release, AllProductID)
    then begin
      for I := 1 to GetArrayLength(AllProductID) do begin
        ProductID := AllProductID[I-1];
        KeyPathLong := KeyPathShort + Release + '\' + ProductID + '\Applications\MyCADApp';
        KeyStringLong := KeyStringShort + RunTimeNum + '.x64.arx';
        RegWriteDWordValue (HKLM64, KeyPathLong,'LOADCTRLS', 2);
        RegWriteStringValue (HKLM64, KeyPathLong,'LOADER',KeyStringLong);
      end;
    end;
end;

An example of its useage - to test for ACAD 2012 and ACAD 2013 and add the registry entries triggered by an end installation event you would add the following code:

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep=ssPostInstall
    then begin
        AddAcadRegKey ('R18.2');{ACAD 2012}
        AddAcadRegKey ('R19.0');{ACAD 2013}
   end;
end;

您将在该讨论帖中找到更多信息。


这是我在注册表中检查的一个示例:

现在,我向您展示的代码创建了这些密钥:

RegWriteDWordValue (HKLM64, KeyPathLong,'LOADCTRLS', 2);
RegWriteStringValue (HKLM64, KeyPathLong,'LOADER',KeyStringLong);

你真的试过了吗?你为什么不手动将你的 VLX 添加到启动套件中,然后查看对注册表所做的更改?然后你就知道你需要做什么了。

还有信息here,我在Google中搜索了一下:

加载 .NET 程序集

After you have determined the build type of your .NET assembly, you must determine how it will be loaded into AutoCAD. A .NET assembly file can be loaded manually or with demand loading.

  • Manually - Use the NETLOAD command at the Command prompt or within an AutoLISP file.
  • Demand load - Define a key specific to the application you want to load when AutoCAD starts up. The key must be placed under the Application key for the specific release of AutoCAD that you want your application to be loaded in.

The key for the application can contain the following keys:

DESCRIPTION Description of the .NET assembly and is optional.

LOADCTRLS Controls how and when the .NET assembly is loaded.

  • 1 - Load application upon detection of proxy object

  • 2 - Load the application at startup

  • 4 - Load the application at start of a command

  • 8 - Load the application at the request of a user or another application

  • 16 - Do not load the application

  • 32 - Load the application transparently

LOADER Specifies which .NET assembly file to load.

MANAGED Specifies the file that should be loaded is a .NET assembly or ObjectARX file. Set to 1 for .NET assembly files.

您应该使用自动加载程序包格式。这样您就不必弄乱注册表项,您的 Inno Setup 脚本只需安装到用户数据文件夹、Program Data 或 Program Files 下的 Autodesk\ApplicationPlugins 文件夹中。