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
|