Finding basic ACAD version from registry

Finding basic ACAD version from registry

Anonymous
Not applicable
453 Views
4 Replies
Message 1 of 5

Finding basic ACAD version from registry

Anonymous
Not applicable
Hi,

My application need to know about existence of various AutoCAD installations in a PC, before it can start its work.

I just need to know the basic version ONLY. For example R15 for AutoCAD 2002 & ADT 3.3 and R16 for AutoCAD 2004 & ADT 2004

For that (just an example), i use the registry key, "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R16.0\ACAD-201:409\Release" and get the value "16.0.0.086" for R16 and soforth for other versions.

The problem is ADT 2004 has a value for the above key which looks like "4.x.y.z" and not starts with "16."

Becuase of this my application fails and i am unable to RELIABLY (FUTURE PROOF IS NEEDED) know the version number.

It will be of a great help if any prodigies could assist!

Thanx in advance,
Regards
Narayanan
0 Likes
454 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
While I've not yet updated it to work with R16,
have a look in the downloads section of my site (
href="http://code.acadx.com">http://code.acadx.com
). There you'll find
"AcadRegistry" which demonstrates how to programmatically discover which
versions/installations are present on a target system.


--
"It's more important that you know how to find the answer than
to have the answer." - Me


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,

My application need to know about existence of various AutoCAD
installations in a PC, before it can start its work.

I just need to know the basic version ONLY. For example R15 for AutoCAD
2002 & ADT 3.3 and R16 for AutoCAD 2004 & ADT 2004

For that (just an example), i use the registry key,
"HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R16.0\ACAD-201:409\Release" and
get the value "16.0.0.086" for R16 and soforth for other versions.

The problem is ADT 2004 has a value for the above key which looks like
"4.x.y.z" and not starts with "16."

Becuase of this my application fails and i am unable to RELIABLY (FUTURE
PROOF IS NEEDED) know the version number.

It will be of a great help if any prodigies could assist!

Thanx in advance,
Regards
Narayanan

0 Likes
Message 3 of 5

Anonymous
Not applicable
narayanan,



I have done this.....



  

Const ACAD_APP_NAME = "AutoCAD.Application"

Set AutoCadApplication = GetObject(, ACAD_APP_NAME)

sAcadHive = "SOFTWARE\Autodesk\AutoCAD"

sCurrentVersion = ReadRegVal(HKEY_LOCAL_MACHINE, sAcadHive, "CurVer", sVal)

sAutocadVersion = AutoCadApplication.Version

sAutocadVersion = "R" & Left(sAutocadVersion, Len(sCurrentVersion) - 1)

'To Get the Minor Version - we can...

sAcadHive = sAcadHive & "\" & sCurrentVersion

sMinorVersion = ReadRegVal(HKEY_LOCAL_MACHINE, sAcadHive, "CurVer", sVal)

'To Get the AutoCad Product Code we can then

sAcadHive = sAcadHive & "\" & sMinorVersion

sProductCode = ReadRegVal(HKEY_LOCAL_MACHINE, sAcadHive, "ProductCode", sVal)





So the line "sAutocadVersion = "R" & Left(sAutocadVersion, Len(sCurrentVersion) - 1)" will get the major version and then uses the "CurVer" Key to determine where to go next.

In my case CurVer is set to "ACAD-12:409", which means I can append that value to the registry path, and I will be in the correct Hive for this version.



As long as there is a key in HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R16.0\ called CurVer, set to "ACAD-201:409" this will work... I am sure this is the case.

I have have used this code on 13/14/15 and it is OK.

Let me know how you go



Thanks



Justin
0 Likes
Message 4 of 5

Anonymous
Not applicable
Credit where credit is due - the previous post is from my colleague Justin but he somehow picked up a Cookie that put my name in the header.



Regards



Wayne Ivory

IT Analayst Programmer

Wespine Industries Pty Ltd
0 Likes
Message 5 of 5

Anonymous
Not applicable
Dear wivory/Justin,
Thanx for your efforts...
The sample code uses Getobject function. Actually my situation is to use detect the AutoCAD installations, present a form to user and launch it using CREATEOBJECT.

so, since i dont have any AutoCAD sessions running, i cannot use as shown.

I had tried to use RegEnumKeyEx API to scan for available ACAD installations. So, if i start a phrasing from "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD", the next subsequent hives, "R15.0" and "R16.0" will be fetched.
I didnot need to bother to go into R15.0 or R16.0 hive at all and i need not even worry about the vertical product at all!!

The code i am using is as follows (taken from allapi.net)...
(thanx anyhow...)

Const ERROR_NO_MORE_ITEMS = 259&
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, lpcbName As Long, ByVal lpReserved As Long, ByVal lpClass As String, lpcbClass As Long, lpftLastWriteTime As Any) As Long
Private Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpValueName As String, lpcbValueName As Long, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long

Public Sub ScanForAutoCADInstallations()
Dim hKey As Long, Cnt As Long, sName As String, sData As String, Ret As Long, RetData As Long
Const BUFFER_SIZE As Long = 255
Ret = BUFFER_SIZE
' Open the registry key
If RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Autodesk\AutoCAD", hKey) = 0 Then
' Create a buffer
sName = Space(BUFFER_SIZE)
' Enumerate the keys
While RegEnumKeyEx(hKey, Cnt, sName, Ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_NO_MORE_ITEMS

Form1.List1.AddItem Left$(sName, Ret)
'prepare for the next key
Cnt = Cnt + 1
sName = Space(BUFFER_SIZE)
Ret = BUFFER_SIZE
'Me.Show
Wend
'close the registry key
RegCloseKey hKey
Else
'Me.Print " Error while calling RegOpenKey"
End If
'Me.Print vbCrLf + "RegEnumValue"
Cnt = 0
'Open a registry key

End Sub
0 Likes