Monday, June 27, 2011

Using VB.net to detect Adobe reader was installed,get version number and get installation path

Here is my sub routine to detect if Adobe acrobat reader was installed on my computer,how to get the version number and get the installation path.I search from the internet and made it as a sub routine.Hope it helps who need it.

Private Sub pathAdobeReader()
Dim path, adobe, acroRead As RegistryKey
adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe")
If adobe IsNot Nothing Then
acroRead = adobe.OpenSubKey("Acrobat Reader")
If acroRead IsNot Nothing Then
MsgBox("Acrobat Reader was installed")
Dim acroReadVersions As String() = acroRead.GetSubKeyNames()
For Each versionNumber As String In acroReadVersions
'get the version number
MsgBox(versionNumber)
path = acroRead.OpenSubKey(versionNumber & "\InstallPath", False)
'get the path
Dim value As String = CType(path.GetValue(""), String)
MsgBox(value)
path.Close()
acroRead.Close()
adobe.Close()
Next
Else
MsgBox("Acrobat Reader was not installed")
End If
End If
End Sub

No comments: