.NET

Reply
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 1 of 5 (139 Views)

Register registry value with dotnet.

139 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
rubendm
Posts: 39
Registered: ‎12-04-2006
Message 2 of 5 (139 Views)

Re: Register registry value with dotnet.

01-08-2007 11:04 AM 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 :-)
Mentor
MarkPendergraft
Posts: 375
Registered: ‎06-27-2005
Message 3 of 5 (139 Views)

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

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 :smileyhappy:

-Mark Pendergraft
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 4 of 5 (139 Views)

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.
/R16.2......
Some more help,plz.
Thanks.
Mentor
MarkPendergraft
Posts: 375
Registered: ‎06-27-2005
Message 5 of 5 (139 Views)

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

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.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.