RemoveOption Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use this method to delete an option from the current section. The option is identified by its name. To get a list of names for all options in the section, use the GetOptionNames method.

Declaration

ProgObj.RemoveOption(OptionName)

ProgObj An expression, variable or parameter that specifies a reference to one of the objects listed in the Applies To section
OptionName [in]    Required    String    
Result None

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

OptionName

Specifies the name of the option to be deleted.

Result Value

None.

Remarks

Be careful when modifying the system registry using the Section object methods. Incorrect modifications made to the registry may affect the functionality of your operating system and the applications installed.

Example

The following code snippet deletes the registry key value.

JavaScript, JScript

function Test()
{

  var Key, Value;
  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER);
  // Specifies the name of the value to be deleted
  Value = "ValueName";
  if (Key.OptionExists(Value))
    {
    // Removes the specified value
    Key.RemoveOption(Value);
    Log.Message("The value has been deleted");
    }

}

Python

def Test():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey\\Subkey", HKEY_CURRENT_USER)
  # Specifies the name of the value to be deleted
  Value = "ValueName"
  if (Key.OptionExists(Value)):
    # Removes the specified value
    Key.RemoveOption(Value)
    Log.Message("The value has been deleted")

VBScript

Sub Test

  Dim Key, Value
  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey\Subkey", HKEY_CURRENT_USER)
  ' Specifies the name of the value to be deleted
  Value = "ValueName"
  If Key.OptionExists(Value) Then
    ' Removes the specified value
    Key.RemoveOption(Value)
    Log.Message("The value has been deleted")
  End If

End Sub

DelphiScript

procedure Test();
var Key, Value;
begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey\Subkey', HKEY_CURRENT_USER);
  // Specifies the name of the value to be deleted
  Value := 'ValueName';
  if Key.OptionExists(Value) then
    begin
    // Removes the specified value
    Key.RemoveOption(Value);
    Log.Message('The value has been deleted');
    end;

end;

C++Script, C#Script

function Test()
{

  var Key, Value;
  // Gets an object for the Windows system registry key
  Key = Storages["Registry"]("TestKey\\Subkey", HKEY_CURRENT_USER);
  // Specifies the name of the value to be deleted
  Value = "ValueName";
  if (Key["OptionExists"](Value))
    {
    // Removes the specified value
    Key["RemoveOption"](Value);
    Log["Message"]("The value has been deleted");
    }

}

See Also

GetOptionNames Method
RemoveOptionByIndex Method
DeleteSubSection Method

Highlight search results