Distinguished Contributor
177 Posts
0 Kudos
Registered: ‎09-05-2006
Post 1 of 5

Register registry value with dotnet.

144 Views, 4 Replies
12-28-2006 03:03 PM
Dear all.
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.

Imports Autodesk.AutoCAD.Runtime
Imports Microsoft.Win32
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")
End If
End Sub
End Class
Active Contributor
39 Posts
0 Kudos
Registered: ‎12-04-2006
Post 2 of 5

Re: Register registry value with dotnet.

01-08-2007 11:04 AM in reply to: gilseorin
Take a look at this article:


Hope this helps :-)
385 Posts
10 Kudos
Registered: ‎06-27-2005
Post 3 of 5

Re: Register registry value with dotnet.

01-08-2007 03:53 PM in reply to: gilseorin
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.

Sub InitialRegistryEditor()
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.")
Exit Sub
End If
Catch ex As Exception
Console.WriteLine(vbCrLf + "Press Any Key to Continue...")
End Try
End Sub

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.

I hope that helps :smileyhappy:

-Mark Pendergraft
Distinguished Contributor
177 Posts
0 Kudos
Registered: ‎09-05-2006
Post 4 of 5

Re: Register registry value with dotnet.

01-12-2007 12:54 PM in reply to: gilseorin
Thank you so much for your reply.
Your code works very well, but only one problem occurs.
The following registry is created dupulicatedly.
Some more help,plz.
385 Posts
10 Kudos
Registered: ‎06-27-2005
Post 5 of 5

Re: Register registry value with dotnet.

01-12-2007 01:06 PM in reply to: gilseorin
My guess is that you have Acad 2007. Where as i have 2006.

from reading your original post, it's likely you will need to change the following key:

SOFTWARE\Autodesk\AutoCAD\R16.2 \ACAD-4008:409\Applications



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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post