GetSectionNames Method

Applies to TestComplete 15.44, last modified on November 10, 2022

Description

Use this method to get the names of all subsections in the current section. Subsection names are listed in a string where they are delimited by line breaks. To get the number of subsections in this collection, use the SectionCount property. To get the name of a subsection by its index in this collection, use the GetSectionName method.

Declaration

ProgObj.GetSectionNames()

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

Applies To

The method is applied to the following objects:

Result Value

The names of all subsections in the current section delimited by line breaks.

Example

The following code snippet obtains the names of the subkeys that belong to the specified registry key and posts them to the Details panel of the test log.

JavaScript, JScript

function Test()
{

  var Key, Name, SubKeys, Count;
  // Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER, AQRT_32_BIT, true)
  Name = Key.Name;
  // Determines how many keys the current key contains
  Count = Key.SectionCount;
  if (Count > 0)

    {
    // Gets the names of the keys and posts them to the Details panel
    SubKeys = Key.GetSectionNames();
    Log.Message("The " + Name + " registry key contains the following subkeys:", SubKeys);
    }

}

Python

def Test():

  # Gets an object for the Windows system registry key
  Key = Storages.Registry("TestKey", HKEY_CURRENT_USER, AQRT_32_BIT, True)
  Name = Key.Name
  # Determines how many keys the current key contains
  Count = Key.SectionCount
  if (Count > 0):

    # Gets the names of the keys and posts them to the Details panel
    SubKeys = Key.GetSectionNames()
    Log.Message("The " + Name + " registry key contains the following subkeys:", SubKeys)

VBScript

Sub Test

  Dim Key, Name, SubKeys, Count
  ' Gets an object for the Windows system registry key
  Set Key = Storages.Registry("TestKey", HKEY_CURRENT_USER, AQRT_32_BIT, True)
  Name = Key.Name
  ' Determines how many keys the current key contains
  Count = Key.SectionCount
  If Count > 0 Then

    ' Gets the names of the keys and posts them to the Details panel
    SubKeys = Key.GetSectionNames
    Call Log.Message("The " & Name & " registry key contains the following subkeys:", SubKeys)
  End If

End Sub

DelphiScript

procedure Test();
var Key, Name, SubKeys, Count;
begin

  // Gets an object for the Windows system registry key
  Key := Storages.Registry('TestKey', HKEY_CURRENT_USER, AQRT_32_BIT, true);
  Name := Key.Name;
  // Determines how many keys the current key contains
  Count := Key.SectionCount;
  if Count > 0 then

    begin
    // Gets the names of the keys and posts them to the Details panel
    SubKeys := Key.GetSectionNames();
    Log.Message('The ' + Name + ' registry key contains the following subkeys:', SubKeys);
    end;

end;

C++Script, C#Script

function Test()
{

  var Key, Name, SubKeys, Count;
  // Gets an object for the Windows system registry key
  Key = Storages["Registry"]("TestKey", HKEY_CURRENT_USER, AQRT_32_BIT, true)
  Name = Key["Name"];
  // Determines how many keys the current key contains
  Count = Key["SectionCount"];
  if (Count > 0)

    {
    // Gets the names of the keys and posts them to the Details panel
    SubKeys = Key["GetSectionNames"]();
    Log["Message"]("The " + Name + " registry key contains the following subkeys:", SubKeys);
    }

}

See Also

GetOptionNames Method
GetSectionName Method
SectionCount Property

Highlight search results