<div class="content" name="RpcFilterByState" uuid="14ed1d68-71f2-4495-9946-0116f87ee1ee"><p>The RpcFilterByState method adds a filter to the session
enumeration result, running on a <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_b416f72e-cf04-4d80-bf93-f5753f3b0998" data-linktype="relative-path">terminal server</a></span>,
based on the state of the sessions. This method MUST be called after <span><a href="f17f4b8d-8d52-4538-acf3-cdfbe581a99b" data-linktype="relative-path">RpcOpenEnum</a></span>
and before <span><a href="1a7d5d1d-1ce5-448f-bb4a-c79741982edb" data-linktype="relative-path">RpcGetEnumResult</a></span> or
<span><a href="cb2be084-41dd-44ec-81dc-52d371a28554" data-linktype="relative-path">RpcGetEnumResultEx</a></span>.
No special permissions are required to call this method.</p><dl>
<dd>
<div><pre> HRESULT RpcFilterByState(
   [in] ENUM_HANDLE hEnum,
   [in] LONG State,
   [in] BOOL bInvert
 );
</pre></div>
</dd></dl><p><b>hEnum: </b> The <span><a href="c41d3367-04c9-4c93-babf-9b5de834eb29#gt_5044babb-08e3-4bb9-bc12-fe8f542b05ee" data-linktype="relative-path">handle</a></span> to the
session enumeration object. This is of type <span><a href="15f02d59-200a-435d-a07b-055e1276d01c" data-linktype="relative-path">ENUM_HANDLE</a></span>.</p><p><b>State: </b>The session state, as specified in
section <span><a href="58b06e1d-bfe4-4a2f-90a1-9c9129923e99" data-linktype="relative-path">3.3.4.1.8</a></span>, to be
used to filter out the enumeration result. Only the sessions with the specified
state will be returned.</p><p><b>bInvert: </b> Set to TRUE to imply that the result
of the comparison during enumeration will be inverted, FALSE otherwise.</p><p><b>Return Values: </b> The method MUST return S_OK
(0x00000000) on success; otherwise, it MUST return an implementation-specific
negative value.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 S_OK</td>
  <td>Successful completion.</td>
 </tr></tbody></table>
</dd></dl><p> </p></div>