Partager via


CHStringArray::InsertAt(int, LPCWSTR, int) method

[The CHStringArray class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

The InsertAt method inserts an element (or multiple copies of an element) at a specified index in an array. The element at the specified index and all elements to its right shift up by one index value for each copy inserted.

Syntax

void InsertAt(int, LPCWSTR, int)(
   int     nIndex,
   LPCWSTR newElement,
   int     nCount = 1
) throw (CHeap_Exception);

Parameters

  • nIndex
    An integer index that can be greater than the value returned by GetUpperBound.

  • newElement
    The CHString pointer to be placed in this array.

  • nCount
    The number of times this element should be inserted. The default is 1.

Return value

This method does not return a value.

Examples

The following code example shows the use of CHStringArray::InsertAt(int, LPCWSTR, int).

CHStringArray a;
CHString s(L"String 6");
int idx, size;

a.Add(L"String 1");
a.Add(L"String 2");
a.Add(L"String 3");
a.Add(L"String 4");

a.InsertAt(5,L"String 5");
a.InsertAt(2,s,2);
a.InsertAt(1,L"String 7");

size = a.GetSize();
for (idx = 0 ; idx < size ; idx++)
   printf("[%d]: %S\n", idx, (LPCWSTR)a[idx]);

The results from this program are as follows.

String 1
String 7
String 2
String 6
String 6
String 3
String 4

String 5

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

ChStrArr.h (include FwCommon.h)

Library

FrameDyn.lib

DLL

FrameDynOS.dll; FrameDyn.dll

See also

CHStringArray

CHStringArray::Add

CHStringArray::RemoveAt

CHStringArray::SetAt