<div class="content" name="BuildContextW" uuid="fc4bf100-2799-4acf-a537-625f9c98500b"><p>The BuildContextW method is equivalent in all ways to the <a href="bdb686a6-1190-4900-9dd5-2f9aac6ca621" data-linktype="relative-path">BuildContext</a> method,
except that its string parameters are encoded in UTF-16. The <a href="2b0e7911-f115-477a-92db-2d9bd5a69ca8#gt_9c5903c1-1477-4181-b451-3ba1e34a0c0c" data-linktype="relative-path">MIDL</a> syntax of the method
is as follows.</p><dl>
<dd>
<div><pre> HRESULT BuildContextW(
   [in] handle_t hBinding,
   [in] SESSION_RANK sRank,
   [in] BIND_VERSION_SET BindVersionSet,
   [in, string, range(GUID_LENGTH, GUID_LENGTH)] 
     wchar_t pwszCalleeUuid[],
   [in, string, range(1, MAX_COMPUTERNAME_LENGTH+1)] 
     wchar_t pwszHostName[],
   [in, string, range(GUID_LENGTH, GUID_LENGTH)] 
     wchar_t pwszUuidString[],
   [in, string, range(GUID_LENGTH, GUID_LENGTH)] 
     wchar_t pwszGuidIn[],
   [in, out, string, range(GUID_LENGTH, GUID_LENGTH)] 
     wchar_t pwszGuidOut[],
   [in, out] BOUND_VERSION_SET* pBoundVersionSet,
   [in, range(sizeof(BIND_INFO_BLOB), sizeof(BIND_INFO_BLOB))] 
     DWORD dwcbSizeOfBlob,
   [in, size_is(dwcbSizeOfBlob)] unsigned char rguchBlob[],
   [out] PPCONTEXT_HANDLE ppHandle
 );
</pre></div>
</dd></dl><p><b>hBinding: </b><a href="2b0e7911-f115-477a-92db-2d9bd5a69ca8#gt_8a7f6700-8311-45bc-af10-82e10accd331" data-linktype="relative-path">RPC</a> primitive binding
handle, as specified in <a href="https://go.microsoft.com/fwlink/?LinkId=89824" data-linktype="external">[C706]</a>
part 3.</p><p><b>sRank: </b>The rank of the caller.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>SRANK_PRIMARY 0x01</td>
  <td>The caller is the primary partner in this session.</td>
 </tr><tr>
  <td>SRANK_SECONDARY 0x02</td>
  <td>The caller is the secondary partner in this session.</td>
 </tr></tbody></table>
</dd></dl><p><b>BindVersionSet: </b>A <a href="1808d4f0-3842-47bc-8c5b-a177f2ede4d0" data-linktype="relative-path">BIND_VERSION_SET</a> structure
that contains the minimum and maximum versions supported by the <a href="2b0e7911-f115-477a-92db-2d9bd5a69ca8#gt_7b0ee975-d1b4-4a39-865d-d13e6c96aa76" data-linktype="relative-path">partner</a>.</p><p><b>pwszCalleeUuid: </b>The string form of the
callee&#39;s <a href="2b0e7911-f115-477a-92db-2d9bd5a69ca8#gt_008df1ed-6dde-44be-be73-57a5008782ca" data-linktype="relative-path">contact identifier
(CID)</a>. The contact identifier (CID) MUST match the contact identifier (CID)
in the callee&#39;s local name object and MUST be formatted into a string.</p><p><b>pwszHostName: </b>The string form of the caller&#39;s
host name. This host name identifies the machine in which the caller&#39;s instance
of the MSDTC Connection Manager: OleTx Transports Protocol is running. This
MUST be a <a href="2b0e7911-f115-477a-92db-2d9bd5a69ca8#gt_0334e0bd-2755-42f6-aeff-2d4a22bf4abf" data-linktype="relative-path">NetBIOS name</a>.
For NetBIOS, see <a href="https://go.microsoft.com/fwlink/?LinkId=90224" data-linktype="external">[NETBEUI]</a>,
<a href="https://go.microsoft.com/fwlink/?LinkId=90260" data-linktype="external">[RFC1001]</a>, and <a href="https://go.microsoft.com/fwlink/?LinkId=90261" data-linktype="external">[RFC1002]</a>.</p><p><b>pwszUuidString: </b>The string form of the
caller&#39;s contact identifier (CID). This contact identifier (CID) identifies the
caller&#39;s instance of the MSDTC Connection Manager: OleTx Transports Protocol.
This MUST match the contact identifier (CID) in the caller&#39;s local name object
and MUST be formatted into a string.</p><p><b>pwszGuidIn: </b>A string form of a UUID that
represents a unique identifier for this bind attempt. The UUID MUST be
formatted into a string.</p><p><b>pwszGuidOut: </b>A string form of a UUID that
represents a unique identifier for this bind attempt. On input, the <i>pwszGuidOut</i>
parameter MUST be set to 00000000-0000-0000-0000-000000000000. On return, if
the bind attempt is ultimately successful, the <i>pwszGuidOut</i> parameter
MUST be equal to the value of the <i>pszGuidIn</i> parameter. Otherwise, if the
bind attempt is ultimately unsuccessful, the <i>pwszGuidOut</i> parameter MUST
be set to 00000000-0000-0000-0000-000000000000 on return.</p><p><b>pBoundVersionSet: </b>A pointer to a <a href="1a0b77a6-65cc-4aa0-99a4-da4277b35ec1" data-linktype="relative-path">BOUND_VERSION_SET</a>
structure. When the method is called, every field of the BOUND_VERSION_SET
structure MUST be initialized to zero. This parameter receives a
BOUND_VERSION_SET on successful completion and also on return.</p><p><b>dwcbSizeOfBlob: </b>The count in bytes of the size
of the binding info structure. This parameter MUST be set to the size of <a href="7de5e521-b2fa-46f8-8e12-094e0630909d" data-linktype="relative-path">BIND_INFO_BLOB</a>, 8.</p><p><b>rguchBlob: </b>A byte array that contains a
BIND_INFO_BLOB structure. </p><p><b>ppHandle: </b>On successful return, an RPC context
handle (see [C706]) that correlates with the session object created by, or
referenced by, this method.</p><p><b>Return Values: </b>This method MUST return zero
(0x00000000) on success. On failure, it MUST return either 0x80000172
(E_CM_VERSION_SET_NOTSUPPORTED) or an implementation-specific <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>.
A client SHOULD distinguish between 0x80000172 and other error codes, as
specified in sections <a href="a0f6d5af-4866-454d-8d33-5a983d893a7c" data-linktype="relative-path">3.3.4.2.1</a>
and <a href="39557ed1-8073-4deb-8922-109d6a25edaa" data-linktype="relative-path">3.3.4.2.2</a>, but MUST
NOT depend on implementation-specific failure HRESULT values. From an
over-the-wire communication point of view, the client MUST implement only
behaviors for the errors described in the following table.</p><dl>
<dd>
<p>Standard errors are defined in <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>
section <a href="../ms-erref/08834f40-5300-492f-a11a-591769b3d60a" data-linktype="relative-path">4</a>.</p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 ERROR_STATUS</td>
  <td>The return value indicates success.</td>
 </tr><tr>
  <td>0x80000172 E_CM_VERSION_SET_NOTSUPPORTED</td>
  <td>The return value indicates that the callee partner does not support the caller&#39;s BindVersionSet parameter and will not execute the requested operation.</td>
 </tr><tr>
  <td>0x000006D1 RPC_S_PROCNUM_OUT_OF_RANGE</td>
  <td>The return value indicates that the caller does not support this call.</td>
 </tr><tr>
  <td>0x80000124 E_CM_S_TIMEDOUT</td>
  <td>The return value indicates that the callee timed out while waiting for the caller to complete the bind. This value is returned by a secondary partner to a primary partner if the primary partner does not return from the secondary partner&#39;s call to BuildContext within half the amount of time specified in the Session Setup Timer (section 3.2.2.1).</td>
 </tr><tr>
  <td>0x000006BB RPC_S_SERVER_TOO_BUSY</td>
  <td>The return value indicates that the partner is too busy to complete this operation. For more information, see [MS-RPCE] section 3.1.1.5.5.</td>
 </tr><tr>
  <td>0x80000173 E_CM_S_PROTOCOL_NOT_SUPPORTED</td>
  <td>The return value indicates that none of the protocols described in the rguchBlob parameter is supported by the partner.</td>
 </tr><tr>
  <td>0x80070057 E_INVALIDARG</td>
  <td>The return value indicates that one of the specified arguments is invalid.</td>
 </tr></tbody></table>
</dd>
<dd>
<p>The following table describes the possible
implementation-specific errors that SHOULD be returned by this method.</p>
</dd>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x80000120 E_CM_SESSION_DOWN</td>
  <td>In a scenario where the value of the sRank parameter is SRANK_SECONDARY, if BuildContextW is called and an existing session object is not found, the call SHOULD return this value.&lt;30&gt;</td>
 </tr><tr>
  <td>0x80000123 E_CM_SERVER_NOT_READY</td>
  <td>The session object is not in the Connecting state.&lt;31&gt;</td>
 </tr></tbody></table>
</dd></dl><p>When a partner calls BuildContextW on another partner, an
error code of RPC_S_PROCNUM_OUT_OF_RANGE means that the callee does not support
BuildContextW.</p></div>