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 internationalization information from the registry
Keywordsinternationalization, registry
CategoriesTips and Tricks, Strings
 
Use the RegOpenKeyEx API function to open a key. Function GetRegistryValue uses the RegQueryValueEx API function to read and return a subkey value. Use RegCloseKey to close the key when finished reading subkey values.

To get the internationalization information, look in HKEY_CURRENT_USER\Control Panel\International.

 
Private Sub Form_Load()
Dim hKey As Long

    ' Open the key.
    If RegOpenKeyEx(HKEY_CURRENT_USER, _
        "Control Panel\International", _
        0&, KEY_ALL_ACCESS, hKey) <> ERROR_SUCCESS _
    Then
        MsgBox "Error opening key."
        Exit Sub
    End If
    
    ' Get the subkeys' values.
    lbliDate.Caption = GetRegistryValue(hKey, "iDate")
    lbliMeasure.Caption = GetRegistryValue(hKey, "iMeasure")
    lblLocale.Caption = GetRegistryValue(hKey, "Locale")
    lblsDate.Caption = GetRegistryValue(hKey, "sDate")
    lblsDecimal.Caption = GetRegistryValue(hKey, "sDecimal")
    lblsShortDate.Caption = GetRegistryValue(hKey, _
        "sShortDate")
    lblsThousand.Caption = GetRegistryValue(hKey, _
        "sThousand")
    
    ' Close the key.
    If RegCloseKey(hKey) <> ERROR_SUCCESS Then
        MsgBox "Error closing key."
    End If
End Sub

' Return the registry value.
Private Function GetRegistryValue(ByVal hKey As Long, ByVal _
    subkey_name As String) As String
Dim value As String
Dim length As Long
Dim value_type As Long

    length = 256
    value = Space$(length)
    If RegQueryValueEx(hKey, subkey_name, _
        0&, value_type, ByVal value, length) _
            <> ERROR_SUCCESS _
    Then
        value = "<Error>"
    Else
        ' Remove the trailing null character.
        value = Left$(value, length - 1)
    End If
    
    GetRegistryValue = value
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated