Community
I need to list all the profiles on a given machine and add a new profile if its not in the list. Is this possible in c#? Can anyone point me in the right direction as i cant find anything conclusive when i searched
Hi,
search in the registry, there you can find all AutoCAD versions installed plus all profiles in every from these installations (inlcuding vertical products based on AutoCAD).
The path to search is:
HKCU\Software\Autodesk\AutoCAD\Rxx.x\ACAD-yyyy:yyy\Profiles
- alfred -
Try to play around with this code
Private Function GetAcadVer() As String Dim acadver As Object Try acadver = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\AutoCAD.Application\CurVer", _ String.Empty, String.Empty) If TypeOf acadver Is String Then Return acadver.ToString() Else Return Nothing End If Catch Return Nothing End Try End Function Private Function GetAcadKind() As String Dim appver As Object Dim acadkind As Object Try appver = TryCast(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD", "CurVer", Nothing), Object) If appver IsNot Nothing Then acadkind = TryCast(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD" + "\" + appver, "CurVer", Nothing), Object) Return "HKEY_CURRENT_USER\Software\Autodesk\AutoCAD" + "\" + appver.ToString() + "\" + acadkind.ToString() Else Return Nothing End If Catch Return Nothing End Try End Function Public Sub TestProfiles() Dim profiles As Object profiles = My.Computer.Registry.GetValue(GetAcadKind() + "\Profiles", _ String.Empty, String.Empty) If TypeOf profiles Is String Then MessageBox.Show("String profiles: " & profiles.ToString()) ElseIf TypeOf profiles Is Integer Then MessageBox.Show("Integer profiles: " & CInt(profiles)) ElseIf TypeOf profiles Is String() Then MessageBox.Show("String array: ") Dim dataArray() As String = DirectCast(profiles, String()) For ctr As Integer = LBound(dataArray, 1) To UBound(dataArray, 1) MessageBox.Show(" " & dataArray(ctr)) Next ElseIf TypeOf profiles Is Byte() Then MessageBox.Show("Binary profiles: ") Dim byteArray() As Byte = DirectCast(profiles, Byte()) For ctr As Integer = LBound(byteArray, 1) To UBound(byteArray, 1) MessageBox.Show(" " & Hex(byteArray(ctr)) & " ") Next Else MessageBox.Show("Unknown Profiles type...") End If End Sub
~'J'~
Can't find what you're looking for? Ask the community or share your knowledge.