.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Register registry value with dotnet.

4 REPLIES 4
Reply
Message 1 of 5
gilseorin
524 Views, 4 Replies

Register registry value with dotnet.

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
4 REPLIES 4
Message 2 of 5
rubendm
in reply to: gilseorin

Take a look at this article:

http://through-the-interface.typepad.com/through_the_interface/2006/09/automatic_loadi.html

Hope this helps 🙂
Message 3 of 5
MarkPendergraft
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

Try
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
My.Computer.Registry.LocalMachine.GetAccessControl()
'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)
Else
Console.WriteLine("The Key does not exist on your machine.")
Console.WriteLine("Please speak to your IT Professional to determine the issue.")
Console.WriteLine("Exiting....")
Exit Sub
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
Console.WriteLine(vbCrLf + "Press Any Key to Continue...")
Console.ReadKey()
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 🙂

-Mark Pendergraft
Message 4 of 5
gilseorin
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.
/R16.2......
Some more help,plz.
Thanks.
Message 5 of 5
MarkPendergraft
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

to:

SOFTWARE\Autodesk\AutoCAD\R17.0\ACAD-5001: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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost