Bcc.GetRegValue(Path, Name, DefaultVal)

Description

This function is utilized to get data from the Windows Registry.

Parameters


  • Path – the full path of the registry key beginning with a valid registry root, such as "HKEY_CURRENT_USER".
  • Name – The name of the value you wish to retrieve
  • DefaultVal – the value that will be returned if the value is not found in the registry

Return

Returns a table containing the data of the registry value.  They key values are shown below:


  • ValueName - string containing the registry value name that was found
  • Type - string containing the type of registry value from the list below:
    • REG_BINARY
    • REG_DWORD
    • REG_QWORD
    • REG_SZ
    • REG_MULTI_SZ
    • REG_UNKNOWN - Only returned when the Name is not found
  • Value - the value stored in the named value (or will return the passed DefaultVal if the registry value is not found).  The information in this changes depending on the type of the value as shown below:
    • REG_BINARY - the byte array will be converted to a double value and the value will contain the decimal number
      • The actual Byte array will be returned a separate key value pair for this type.
    • REG_DWORD - a number
    • REG_QWORD - a number
    • REG_SZ - a string
    • REG_MULTI_SZ - a table containing each line of the string as each element
    • REG_EXPAND_SZ - a string will be returned and will provide the type REG_SZ so this type will actually never been seen.
    • REG_UNKNOWN - the DefaultVal passed will be returned as the value was not found
  • ByteArray - This key will be returned when the type is REG_BINARY which will contain a table of the byte array

Examples

-- Get the registry value for the default Milling machine

val = Bcc.GetRegValue("HKEY_CURRENT_USER\\SOFTWARE\\BobCAD-CAM\\BobCAD V35\\Settings\\", "Mill Default Machine", -1)


if val ~= nil then

       Bcc.ShowMessageBox(val.Value)

end


Result