I found the method of registry in dotnet.
How should I use this to register registry value with dotnet to autoload my dll file? Some help? Thanks.
Public Class GILSclass _
Public Sub RS()
Dim strValue As String
Dim strPath As String
strPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.0\ACAD-5001:409\Applications\GILSEORIN\LVM.dll"
strValue = Registry.GetValue(strPath, "LOADER/REG_SZ", "C:\LVM.dll")
If strValue = "Fail" Then
Registry.SetValue(strPath, "DESCRIPTION/REG_SZ", "MyApp")
Registry.SetValue(strPath, "LOADER/REG_SZ", "C:\LVM.dll")
Registry.SetValue(strPath, "LOADCTRLS/REG_DWORD", "2")
Registry.SetValue(strPath, "MANAGED/REG_DWORD", "1")
You should write a program to deploy your program.
Thats what i did. I wrote a console application, and then sent a link in an email to everyone in my company. When they clicked it, it copied the necessary files, and then wrote the correct values to the registry......
Here is the program.
Dim AppKey As RegistryKey = Nothing
Dim CommandKey As RegistryKey = Nothing
Dim VersionKey As RegistryKey = Nothing
Dim TempVal As Object = Nothing
Console.WriteLine(vbCrLf + "LDD Registry Editor. Created by Mark Pendergraft" + vbCrLf + "Attempting to access the registry...." + vbCrLf)
'If this key doesn't exist, they don't have AutoCAD 2006 - Version Specific as far as i know!!!
If Not My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R16.2\ACAD-4008:409", "AcadLocation", Nothing) Is Nothing Then
'Get the key, seeing that it exists
AppKey = My.Computer.Registry.LocalMachine.CreateSubKey("SOFTWARE\Autodesk\AutoCAD\R16.2\ACAD-4008:409\Applications\MRPTools")
'let the user know whats happening
Console.WriteLine("Successfuly Created " + AppKey.ToString)
'These are the values you will have to write (for 2006)
AppKey.SetValue("DESCRIPTION", "MRPTools", RegistryValueKind.String)
'this is where the dll file resides on your machine
AppKey.SetValue("LOADER", "C:\Program Files\Autodesk Land Desktop 2006\NET\MRPTools.dll", RegistryValueKind.String)
AppKey.SetValue("LOADCTRLS", 2, RegistryValueKind.DWord)
AppKey.SetValue("MANAGED", 1, RegistryValueKind.DWord)
CommandKey = AppKey.CreateSubKey("COMMAND")
Console.WriteLine("Successfully Created " + CommandKey.ToString)
'this is a public sub inside MRPTools.dll, You will have to set it to a Public sub residing in your program.
CommandKey.SetValue("LM", "LSMan", RegistryValueKind.String)
Console.WriteLine("The Key does not exist on your machine.")
Console.WriteLine("Please speak to your IT Professional to determine the issue.")
Catch ex As Exception
Console.WriteLine(vbCrLf + "Press Any Key to Continue...")
obviously this is version specific to AutoCAD 2006. But you get the idea. anyways, thats how i deployed my program inside AutoCAD for my company, and it works very well.
In the beginning of the application, where it looks for the value "AcadLocation", the purpose of this is to determine if the user has AutoCAD 2006. If they don't, it alerts them. You should do the same, except modify the string (as shown above) to not only check for 2007, but to write to the 2007 keys as well.
Let me know if that solves your problems.
btw, i would recommend backing up your registry first (just to be safe) and then i would delete any unccessary keys you created. This won't be needed for the end user, but it's a good idea if your testing a program to write to your registry, that you have a backup incase you screw something up.