Find MS PowerPoint's installed Path in VB.NET

Naimishforu
Posted by Naimishforu under VB.NET category on | Points: 40 | Views : 2792
Code:

_component = "powerpnt.exe"

Private Function GetComponentPath(ByVal _component As OfficeComponent) As String

Dim toReturn As String = String.Empty
Dim _key As String = String.Empty

_key = _component

'looks inside CURRENT_USER:
Dim _mainKey As RegistryKey = Registry.CurrentUser
Try
_mainKey = _mainKey.OpenSubKey(RegKey & "\" & _key, False)
If _mainKey IsNot Nothing Then
toReturn = _mainKey.GetValue(String.Empty).ToString()
End If
Catch
End Try

'if not found, looks inside LOCAL_MACHINE:
_mainKey = Registry.LocalMachine
If String.IsNullOrEmpty(toReturn) Then
Try
_mainKey = _mainKey.OpenSubKey(RegKey & "\" & _key, False)
If _mainKey IsNot Nothing Then
toReturn = _mainKey.GetValue(String.Empty).ToString()
End If
Catch
End Try
End If

'closing the handle:
If _mainKey IsNot Nothing Then
_mainKey.Close()
End If

Return toReturn

End Function

Comments or Responses

Login to post response