LexStartup2017 IS THE FIRST ONE.
This is all through the registry
using System;
using System.IO;
using System.Collections.Generic;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using acadApp=Autodesk.AutoCAD.ApplicationServices.Application;
using Microsoft.Win32;
using IP = Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop;
using rkey = Autodesk.AutoCAD.Runtime.RegistryKey;
using Regy = Autodesk.AutoCAD.Runtime.Registry;
[assembly: ExtensionApplication(typeof(Autodesk.AutoCAD.AutoCAD_2017_plug_in1.MyPlugin))]
namespace Autodesk.AutoCAD.AutoCAD_2017_plug_in1
{
public class MyPlugin : IExtensionApplication
{
//HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.2\ACAD-A005:409\Applications
private static string startup = @"C:\Program Files\Autodesk\AutoCAD 2017\Support\LexStartup2017.dll";
private static string GetThangs = @"C:\Program Files\Autodesk\AutoCAD 2017\Support\GetThangs15.dll";
private static Editor ed;
void IExtensionApplication.Initialize()
{
string Keypath = @"Software\Autodesk\AutoCAD\R21.0\ACAD-0001:409\Applications\LexStartup";
//HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R20.0\ACAD-E005:409\Applications
Document doc = acadApp.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
rkey key = Regy.CurrentUser; // Registry.CurrentUser;
key = key.OpenSubKey(Keypath,true);
//ed.WriteMessage
if (key == null)
{
key = Regy.CurrentUser;
key = key.CreateSubKey(Keypath);
key.SetValue("DESCRIPTION", (string)"LexStartup2017.dll autoload", RegistryValueKind.String);
key.SetValue("LOADCTRLS",2,RegistryValueKind.DWord);
key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
key.SetValue("LOADER", startup, RegistryValueKind.String);
}
key.Close();
Keypath = @"Software\Autodesk\AutoCAD\R21.0\ACAD-0001:409\Applications\LexStartup2";
key =Regy.CurrentUser;
key = key.OpenSubKey(Keypath, true);
if (key == null)
{
key = Regy.CurrentUser;
key = key.CreateSubKey(Keypath);
key.SetValue("DESCRIPTION", (string)"GetThangs15.dll autoload", RegistryValueKind.String);
key.SetValue("LOADCTRLS", 2, RegistryValueKind.DWord);
key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
key.SetValue("LOADER", GetThangs, RegistryValueKind.String);
}
key.Close();
//HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R21.0\ACAD - 0005:409
Keypath = @"Software\Autodesk\AutoCAD\R21.0\ACAD-0005:409\Applications\";
//HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R20.0\ACAD-E005:409\Applications
key = Regy.CurrentUser; // Registry.CurrentUser;
key = key.OpenSubKey(Keypath, true);
if (key != null)
{
key.Close();
key = Regy.CurrentUser;
key = key.OpenSubKey(Keypath, true);
Keypath = @"Software\Autodesk\AutoCAD\R21.0\ACAD-0005:409\Applications\LexStartup";
key = key.OpenSubKey(Keypath, true);
if (key == null)
{
key = Regy.CurrentUser;
key = key.CreateSubKey(Keypath);
key.SetValue("DESCRIPTION", (string)"LexStartup2017.dll autoload", RegistryValueKind.String);
key.SetValue("LOADCTRLS", 2, RegistryValueKind.DWord);
key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
key.SetValue("LOADER", startup, RegistryValueKind.String);
}
key.Close();
Keypath = @"Software\Autodesk\AutoCAD\R21.0\ACAD-0005:409\Applications\LexStartup2";
key = Regy.CurrentUser;
key = key.OpenSubKey(Keypath, true);
if ((string)acadApp.GetSystemVariable("Loginname") != "bwalmsley")
{
if (key == null)
{
key = Regy.CurrentUser;
key = key.CreateSubKey(Keypath);
key.SetValue("DESCRIPTION", (string)"GetThangs15.dll autoload", RegistryValueKind.String);
key.SetValue("LOADCTRLS", 2, RegistryValueKind.DWord);
key.SetValue("MANAGED", 1, RegistryValueKind.DWord);
key.SetValue("LOADER", GetThangs, RegistryValueKind.String);
}
key.Close();
}
}