Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleGet the computer's registered owner and company from Windows NT
KeywordsWindows NT, 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 NT\CurrentVersion\RegisteredOrganization
    SOFTWARE\Microsoft\Windows NT\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 NT\CurrentVersion", _
                _
            "RegisteredOrganization")
End Function

' Return a Windows NT registered name.
Private Function RegisteredOwner() As String
    RegisteredOwner = _
        RegistryValue(HKEY_LOCAL_MACHINE, _
            "SOFTWARE\Microsoft\Windows NT\CurrentVersion", _
                _
            "RegisteredOwner")
End Function
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated