Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet the computer's registered owner and company from Windows 98
KeywordsWindows 98, register, registration, owner, company
CategoriesSoftware Engineering, Tips and Tricks
 
The RegistryValue function opens a Registry key and gets a subkey value.

Functions RegisteredOrganization and RegisteredOwner use RegistryValue to get these Registry entries:

    SOFTWARE\Microsoft\Windows\CurrentVersion\RegisteredOrganization
    SOFTWARE\Microsoft\Windows\CurrentVersion\RegisteredOwner
 
' 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated