' Return a registry value.
Private Function RegistryValue(ByVal registry_section As _
Long, ByVal key_name As String, ByVal subkey_name As _
String) As String
Dim hKey As Long
Dim value As String
Dim length As Long
Dim value_type As Long
' Assume there will be trouble.
RegistryValue = "???"
' Open the key.
If RegOpenKeyEx(registry_section, _
key_name, 0&, KEY_ALL_ACCESS, hKey) <> _
ERROR_SUCCESS _
Then Exit Function
' Get the subkey's value.
length = 1024
value = Space$(length)
If RegQueryValueEx(hKey, subkey_name, _
0&, value_type, ByVal value, length) _
<> ERROR_SUCCESS _
Then Exit Function
' Remove the trailing null character.
RegistryValue = Left$(value, length - 1)
' Close the key.
RegCloseKey hKey
End Function
' Return a Windows NT registered organization.
Private Function RegisteredOrganization() As String
RegisteredOrganization = _
RegistryValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion", _
"RegisteredOrganization")
End Function
' Return a Windows NT registered name.
Private Function RegisteredOwner() As String
RegisteredOwner = _
RegistryValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion", _
"RegisteredOwner")
End Function
|