DeleteSubSectionByIndex Method

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

Deletes a subsection from the current section. The subsection is identified by its index in the subsection collection of the current section. To get the number of subsections in this collection, use the SectionCount property.

Declaration

ProgObj.DeleteSubSectionByIndex(Index)

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

Applies To

The method is applied to the following objects:

Parameters

The method has the following parameter:

Index

Specifies the index of the subsection to be deleted. The index is zero-based, that is, the first subsection has index 0, the second - 1, and so on. Index of the last subsection is SectionCount-1.

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 of the specified registry key. The subkey to delete is specified by its index.

JavaScript, JScript

function DeleteSubSectionByIndexDemo()
{

  var Key, Indx;
  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER);
  // Specifies the index of the subkey to delete
  Indx = 0;
  if (Indx < Key.SectionCount)
    {
    // Deletes the specified subkey
    Key.DeleteSubSectionByIndex(Indx);
    Log.Message("The specified registry key has been deleted.");
    }

}

Python

def DeleteSubSectionByIndexDemo():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER)
  # Specifies the index of the subkey to delete
  Indx = 0
  if (Indx < Key.SectionCount):
    # Deletes the specified subkey
    Key.DeleteSubSectionByIndex(Indx)
    Log.Message("The specified registry key has been deleted.")

VBScript

Sub DeleteSubSectionByIndexDemo

  Dim Key, Indx
  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey", HKEY_CURRENT_USER)
  ' Specifies the index of the subkey to delete
  Indx = 0
  If Indx < Key.SectionCount Then
    ' Deletes the specified subkey
    Key.DeleteSubSectionByIndex(Indx)
    Log.Message("The specified registry key has been deleted.")
  End If

End Sub

DelphiScript

procedure DeleteSubSectionByIndexDemo();
var Key, Indx;
begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey', HKEY_CURRENT_USER);
  // Specifies the index of the subkey to delete
  Indx := 0;
  if Indx < Key.SectionCount then
    begin
    // Deletes the specified subkey
    Key.DeleteSubSectionByIndex(Indx);
    Log.Message('The specified registry key has been deleted.');
    end;

end;

C++Script, C#Script

function DeleteSubSectionByIndexDemo()
{

  var Key, Indx;
  // Gets an object for the Windows system registry key
  Key = Storages["Registry"]("TestKey", HKEY_CURRENT_USER);
  // Specifies the index of the subkey to delete
  Indx = 0;
  if (Indx < Key.SectionCount)
    {
    // Deletes the specified subkey
    Key["DeleteSubSectionByIndex"](Indx);
    Log["Message"]("The specified registry key has been deleted.");
    }

}

See Also

Clear Method
DeleteSubSection Method
SectionCount Property
RemoveOptionByIndex Method

Highlight search results