IEnumCERTVIEWROW::GetMaxIndex method (certview.h)

The GetMaxIndex method retrieves the maximum valid index value after all the rows in the row-enumeration sequence have been referenced.


HRESULT GetMaxIndex(
  [out] LONG *pIndex


[out] pIndex

A pointer to a LONG variable that contains the maximum index value for the row-enumeration sequence. This method fails if pIndex is NULL.

Return value


If the method succeeds, the method returns S_OK and pIndex is set to the maximum index value for the row-enumeration sequence.

If traversal to the last row has not occurred, this method fails with a return value of E_UNEXPECTED.

If the method fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.


The return value is the maximum index value for the row-enumeration sequence. This method fails if traversal to the last row has not occurred.


Successful completion of this method is dependent on reaching the last row of the enumeration sequence. The maximum row index can be useful to size a scroll bar or display window, but it can also be resource-intensive to compute because it requires evaluating the entire query. For some queries, column data for each row must be examined to determine whether it is included in the view. After the user has paged through all of the data or explicitly requested to proceed to the end, the maximum row index is preserved.

To navigate through the row-enumeration sequence, call the following methods.

Method Description
IEnumCERTVIEWROW::Reset Moves to the beginning of the enumeration sequence.
IEnumCERTVIEWROW::Next Moves to the next row in the enumeration sequence.
IEnumCERTVIEWROW::Skip Skips a specified number of rows.


#include <windows.h>
#include <stdio.h>
#include <Certview.h>

long nMax;

//  Determine the maximum row index.
hr = pRow->GetMaxIndex(&nMax);
if (FAILED(hr))
    printf("Failed GetMaxIndex [%x]\n", hr);
    printf("Max index is: %d\n", nMax);


Minimum supported client None supported
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header certview.h (include Certsrv.h)
Library Certidl.lib
DLL Certadm.dll

See also