That key would be the best, as it shows us what we need.
I quickly slammed something together for you :
Code:
Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegEnumKey Lib "advapi32.dll" Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, ByVal lpName As String, ByVal cbName As Long) As Long
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const ERROR_SUCCESS = 0&
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_NOTIFY = &H10
Private Const KEY_CREATE_LINK = &H20
Private Const SYNCHRONIZE = &H100000
Private Const KEY_ALL_ACCESS = _
((STANDARD_RIGHTS_ALL Or _
KEY_QUERY_VALUE Or _
KEY_SET_VALUE Or _
KEY_CREATE_SUB_KEY Or _
KEY_ENUMERATE_SUB_KEYS Or _
KEY_NOTIFY Or KEY_CREATE_LINK) And _
(Not SYNCHRONIZE))
' Get the key information for this key and
' its subkeys.
Private Sub GetKeyInfo(ByVal key_name As String)
Dim subkeys As Collection
Dim subkey_num As Integer
Dim subkey_name As String
Dim length As Long
Dim hKey As Long
Dim txt As String
Dim strOpera As String
Dim strMajor As String
Dim strMinor As String
Dim intSpacePos As Integer
strOpera = "Opera"
Set subkeys = New Collection
' Open the key.
If RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
key_name, _
0&, KEY_ALL_ACCESS, hKey) <> ERROR_SUCCESS _
Then
MsgBox "Error opening key."
Exit Sub
End If
' Enumerate the subkeys.
subkey_num = 0
Do
' Enumerate subkeys until we get an error.
length = 256
subkey_name = Space$(length)
If RegEnumKey(hKey, subkey_num, _
subkey_name, length) _
<> ERROR_SUCCESS Then Exit Do
subkey_num = subkey_num + 1
subkey_name = Left$(subkey_name, InStr(subkey_name, Chr$(0)) - 1)
If InStr(1, subkey_name, "Opera") Then 'determine string Opera
strOpera = subkey_name 'set strOpera to Opera key
If InStr(1, subkey_name, " ") Then 'See if space exists
intSpacePos = InStr(1, subkey_name, " ") 'Get index of space
strMajor = Mid$(subkey_name, intSpacePos + 1, 2) 'Find Major version
strMinor = Mid$(subkey_name, intSpacePos + 4, 2) 'Find Minor version
MsgBox subkey_name 'display full version
MsgBox strMajor 'display major version
MsgBox strMinor 'display minor version
End If
End If
Loop
' Close the key.
If RegCloseKey(hKey) <> ERROR_SUCCESS Then
MsgBox "Error closing key."
End If
End Sub
Private Sub Form_Load()
Dim key_name As String
key_name = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
GetKeyInfo (key_name)
End Sub
I went further and added the capability to extract both Major and Minor versions as well.
I am attaching the sample here for you, let me know if come right
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.