Bcc.SetRegValue
Bcc.SetRegValue(Path, Name, Type, Value)
Description
This function is utilized to set data in the Windows Registry, as well as create a key or value if it does not exist.
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 set or create
- Type - string value from options below that defines the type of registry value that will be created
- REG_BINARY - a table containing the binary sets
- REG_BINARY_DOUBLE - a decimal number or a string representing a number. This will actually create a REG_BINARY registry value, but BobCAD will do the conversion of decimal number to binary for you
- REG_DWORD - an integer number or a string representing 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
- Value – the value that will be assigned
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_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 - a table containing the binary sets
- REG_DWORD - a number
- REG_SZ - a string
- REG_MULTI_SZ - a table containing each line of the string as each element
- 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 arrayyeah
Examples
-- Set/Create the a string value to store data used by your lua script
path = "HKEY_CURRENT_USER\\SOFTWARE\\BobCAD-CAM\\MyPlugin\\Settings\\"
val = Bcc.SetRegValue(path, "MyBinary", "REG_BINARY", {31,162,209,29,196,206,100,63})
-- Set/Create the a DWORD value to store data used by your lua script
val = Bcc.SetRegValue(path, "MyDword", "REG_DWORD", 1234)
-- Set/Create the a string value to store data used by your lua script
val = Bcc.SetRegValue(path, "MyString", "REG_SZ", "MyValue")
-- Set/Create the a Multiple string values to store data used by your lua script
val = Bcc.SetRegValue(path, "MyMultiString", "REG_MULTI_SZ", {"Value1", "Value2", "Value3"})
-- Set/Create the an expanded string value to store data used by your lua script
val = Bcc.SetRegValue(path, "MyExpandedString", "REG_EXPAND_SZ", "MyExpandedValue")