DeleteSubSection Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the DeleteSubSection method to delete a subsection from the current section. The subsection is identified by its name. To get a list of names for all subsections in the section, use the GetSectionNames method.

Declaration

ProgObj.DeleteSubSection(SectionName)

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

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

SectionName

Specifies the name of the subsection 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 subkey that belongs to the specified registry key.

JavaScript, JScript

function DeleteSubSectionDemo()
{

  var Key, SubKey;
  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER);
  // Specifies the name of the subkey to delete
  SubKey = "SubKey";
  if (Key.SubSectionExists(SubKey))
    {
    Key.DeleteSubSection(SubKey);
    Log.Message("The " + SubKey + " registry key has been deleted");
    }

}

Python

def DeleteSubSectionDemo():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER)
  # Specifies the name of the subkey to delete
  SubKey = "SubKey"
  if (Key.SubSectionExists(SubKey)):
    Key.DeleteSubSection(SubKey)
    Log.Message("The " + SubKey + " registry key has been deleted")

VBScript

Sub DeleteSubSectionDemo

  Dim Key, SubKey
  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey", HKEY_CURRENT_USER)
  ' Specifies the name of the subkey to delete
  SubKey = "SubKey"
  If Key.SubSectionExists(SubKey) Then
    Key.DeleteSubSection(SubKey)
    Log.Message("The " & SubKey & " registry key has been deleted")
  End If

End Sub

DelphiScript

procedure DeleteSubSectionDemo();
var Key, SubKey;
begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey', HKEY_CURRENT_USER);
  // Specifies the name of the subkey to delete
  SubKey := 'SubKey';
  if Key.SubSectionExists(SubKey) then
    begin
    Key.DeleteSubSection(SubKey);
    Log.Message('The ' + SubKey + ' registry key has been deleted');
    end;

end;

C++Script, C#Script

function DeleteSubSectionDemo()
{

  var Key, SubKey;
  // Gets an object for the Windows system registry key
  Key = Storages["Registry"]("TestKey", HKEY_CURRENT_USER);
  // Specifies the name of the subkey to delete
  SubKey = "SubKey";
  if (Key["SubSectionExists"](SubKey))
    {
    Key["DeleteSubSection"](SubKey);
    Log["Message"]("The " + SubKey + " registry key has been deleted");
    }

}

See Also

Clear Method
DeleteSubSectionByIndex Method
GetSectionName Method
GetSectionNames Method
RemoveOption Method

Highlight search results