<div class="content"><p>The PerflibV2EnumerateCounterSetInstances method retrieves
all active instances of the client-specified <a href="da82a046-4e10-46ab-8da9-3d24bb48a2b2#gt_5ad9937c-a24e-4274-92c8-50ff5f97bf19" data-linktype="relative-path">counterset</a> on the server.</p><dl>
<dd>
<div><pre> error_status_t PerflibV2EnumerateCounterSetInstances(
   [in, string] wchar_t* szMachine,
   [in] GUID* CounterSetGuid,
   [in, range(0, 67108864)] DWORD dwInSize,
   [out] DWORD* pdwOutSize,
   [out] DWORD* pdwRtnSize,
   [out, size_is(dwInSize), length_is(* pdwOutSize)] 
     unsigned char* lpData
 );
</pre></div>
</dd></dl><p><b>szMachine: </b>A <a href="da82a046-4e10-46ab-8da9-3d24bb48a2b2#gt_b069acb4-e364-453e-ac83-42d469bb339e" data-linktype="relative-path">Unicode string</a> specifying a
server name, which is passed directly to the counter providers. Counter providers
can ignore the server name provided by <b>szMachine</b>.</p><p><b>CounterSetGuid: </b>The <a href="da82a046-4e10-46ab-8da9-3d24bb48a2b2#gt_f49694cc-c350-462d-ab8e-816f0103c6c1" data-linktype="relative-path">GUID</a> of the counterset
whose instances are to be enumerated.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>
  <p>0x00000000</p>
  <p>ERROR_SUCCESS</p>
  </td>
  <td>
  <p>The return value indicates success.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000005</p>
  <p>ERROR_ACCESS_DENIED</p>
  </td>
  <td>
  <p>The server returns this value to the client if the
  authentication level of the client is less than
  RPC_C_AUTHN_LEVEL_PKT_PRIVACY. </p>
  </td>
 </tr><tr>
  <td>
  <p>0x00001068</p>
  <p>ERROR_WMI_GUID_NOT_FOUND</p>
  </td>
  <td>
  <p>The server returns this value when it cannot find a
  counterset with the GUID that was specified by the client in the <b>CounterSetGuid</b>
  parameter.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00000008</p>
  <p>ERROR_NOT_ENOUGH_MEMORY</p>
  </td>
  <td>
  <p>The server returns this value to the client when the
  buffer the client has provided is not large enough to accommodate the
  instance information.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00001069</p>
  <p>ERROR_WMI_INSTANCE_NOT_FOUND</p>
  </td>
  <td>
  <p>The server returns this value to the client when there
  are no active instances of the counterset whose information can be returned.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x00001073</p>
  <p>ERROR_WMI_INVALID_REGINFO</p>
  </td>
  <td>
  <p>The server returns this to the client if, for any
  reason when trying to enumerate counterset instances, the information that
  the server expected was different than what the applications exposing <a href="da82a046-4e10-46ab-8da9-3d24bb48a2b2#gt_35645a67-9e0b-4c05-b2d9-3b2b25f2beac" data-linktype="relative-path">performance counters</a>
  returned. For example, the server (through some standard repository),
  expected information about one instance of a counterset to be returned
  (because it was specified as a single-instance counterset), but the
  application actually maintaining the information returned instance
  information about multiple instances of the counterset.</p>
  </td>
 </tr><tr>
  <td>
  <p>0x0000000E</p>
  <p>ERROR_OUTOFMEMORY</p>
  </td>
  <td>
  <p>The server returns this value to the client if, for
  any reason as it tries to return the instance information of the specified
  counterset, it fails to allocate memory.</p>
  </td>
 </tr></tbody></table>
</dd></dl><p><b>dwInSize: </b>The size, in bytes, of the buffer.</p><p><b>pdwOutSize: </b>The total size, in bytes, of the
data that is returned and written to the buffer.</p><p><b>pdwRtnSize: </b>The necessary size, in bytes, to
retrieve all the requested data.</p><p><b>lpData: </b>The buffer that contains the instances
information for the counterset.</p><p><b>Return Values: </b>This method MUST return zero
(ERROR_SUCCESS) for success; otherwise, it MUST return one of the standard
Windows errors, as specified in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d" data-linktype="relative-path">2.2</a>.</p><p>The server MUST return a data array in which each element is
a <a href="d78bcdce-a620-475b-b0dd-7eb9d2ed09f3" data-linktype="relative-path">_PERF_INSTANCE_HEADER</a>
structure that is followed by a null-terminated Unicode string instance name.
The <b>size</b> field of the _PERF_INSTANCE_HEADER structure MUST be the size
of the _PERF_INSTANCE_HEADER structure plus the space that is occupied by the
instance name string; and MUST be an 8-byte multiple.</p><p><img id="MS-PCQ_pict5faf61ee-2004-dd27-fafb-800a286141d0.png" src="ms-pcq_files/image003.png" alt="PerflibV2EnumerateCounterSetInstances return" title="PerflibV2EnumerateCounterSetInstances return" data-linktype="relative-path"/></p><p><b>Figure 3: PerflibV2EnumerateCounterSetInstances return</b></p><p>The following diagram illustrates data size, alignment, and
endianness. In this example, information about two instances of the counterset
is returned by the server. The first instance name is 6 bytes in length, and
the second instance name is 8 bytes in length. The two bytes in padding between
the end of the first instance name string and the beginning of the next
_PERF_INSTANCE_HEADER structure MUST be uninitialized and MUST be ignored by
the client.</p><table>
 <tbody><tr>
  <th><p><br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>1<br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>2<br/>0</p></th>
  <th><p><br/>1</p></th>
  <th><p><br/>2</p></th>
  <th><p><br/>3</p></th>
  <th><p><br/>4</p></th>
  <th><p><br/>5</p></th>
  <th><p><br/>6</p></th>
  <th><p><br/>7</p></th>
  <th><p><br/>8</p></th>
  <th><p><br/>9</p></th>
  <th><p>3<br/>0</p></th>
  <th><p><br/>1</p></th>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">_PERF_INSTANCE_HEADER
  (row 1, <b>Size</b>)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">_PERF_INSTANCE_HEADER
  (row 2, <b>InstanceId</b>)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">Unicode
  string for First Instance Name (row 1)</p>
  </td>
 </tr>
 <tr>
  <td colspan="16">
  <p align="center">First
  Instance Name (row 2)</p>
  </td>
  <td colspan="16">
  <p align="center">Padding
  (MUST be uninitialized)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">_PERF_INSTANCE_HEADER
  (row 1, <b>Size</b>)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">_PERF_INSTANCE_HEADER
  (row 2, <b>InstanceId</b>)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">Unicode
  string for Second Instance Name (row 1)</p>
  </td>
 </tr>
 <tr>
  <td colspan="32">
  <p align="center">Second
  Instance Name (row 2)</p>
  </td>
 </tr>
</tbody></table><p> </p></div>