<div class="content" name="GetSessionInfo" uuid="0c4cd71a-0c75-4008-9ccf-4d5f8bb685b9"><p>The GetSessionInfo method is received by the server in an
RPC_REQUEST packet. In response, the server returns the <a href="1ef0b4e0-d88e-4b60-bc24-c983bec1e088#gt_ffff3f01-8c21-44d3-bbda-0062a1fbda4b" data-linktype="relative-path">terminal services</a> session
information for the various sessions on the computer. The terminal services
session information is returned as a SAFEARRAY of BSTRs. Each BSTR contains the
DomainName, UserName and SessionID in the format DomainName\UserName:SessionID.</p><p>This method also returns the count of the total number of
sessions.</p><p>This method does not return Idle and Disconnected terminal
services sessions. Any null values returned in the SAFEARRAY can be ignored.</p><dl>
<dd>
<div><pre> [id(2), helpstring(&#34;method GetSessionInfo&#34;)] HRESULT GetSessionInfo(
   [in, out] SAFEARRAY(BSTR)* UserNames,
   [in, out] INT* Count
 );
</pre></div>
</dd></dl><p><b>UserNames: </b>A pointer to a <a href="../ms-oaut/2e87a537-9305-41c6-a88b-b79809b3703a" data-linktype="relative-path">SAFEARRAY</a>,
as specified in <a href="../ms-oaut/bbb05720-f724-45c7-8d17-f83c3d1a3961" data-linktype="relative-path">[MS-OAUT]</a>,
of BSTRs containing the terminal services session information. Each BSTR
element in the array contains the DomainName, UserName, and SessionID in the
format DomainName\UserName:SessionID. This is returned to the <a href="1ef0b4e0-d88e-4b60-bc24-c983bec1e088#gt_64520114-7ddc-4f5a-b63d-81d79b9a6693" data-linktype="relative-path">expert</a>.</p><p><b>Count: </b>A pointer to an INT that returns the
number of terminal services sessions on the <a href="1ef0b4e0-d88e-4b60-bc24-c983bec1e088#gt_d27bcedc-ae63-4e15-a0cb-9b371f1820dc" data-linktype="relative-path">novice</a>.</p><p><b>Return Values: </b>A signed 32-bit value
indicating return status. This method MUST return zero to indicate success, or
an <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
error value (as specified in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/705fb797-2175-4a90-b5a3-3918024b10b8" data-linktype="relative-path">2.1.1</a>)
to indicate failure.</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>The call was successful.</td>
 </tr><tr>
  <td>0x80004003 E_POINTER</td>
  <td>The method failed due to an invalid pointer.</td>
 </tr><tr>
  <td>0x8007000E E_OUTOFMEMORY</td>
  <td>The method was unable to allocate required memory.</td>
 </tr></tbody></table>
</dd></dl><p><b>Exceptions Thrown:</b></p><p>No exceptions are thrown beyond those thrown by the
underlying <a href="1ef0b4e0-d88e-4b60-bc24-c983bec1e088#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> protocol <a href="../ms-rpce/290c38b1-92fe-4229-91e6-4fc376610c15" data-linktype="relative-path">[MS-RPCE]</a>.</p></div>