大网数据广告活动
网络与域名解析

Microsoft RPC Binding-Handle Extensions

· 52CE 我爱测

The Microsoft extensions to the IDL language support multiple handle parameters that appear in positions other than the first, leftmost, parameter.

The Microsoft extensions to the IDL language support multiple handle parameters that appear in positions other than the first, leftmost, parameter. The following steps describe the sequence that the MIDL compiler goes through to resolve the binding-handle parameter in DCE-compatibility mode (/osf), and in default (Microsoft-extended) mode.

DCE-compatibility mode

  • Binding handle that appears in first position.
  • Leftmost [in, context_handle] parameter.
  • Implicit binding handle specified by [implicit_handle] or [auto_handle].
  • If no ACF present, default to use of [auto_handle].

Default mode

DCE IDL compilers look for an explicit binding handle as the first parameter. When the first parameter is not a binding handle and one or more context handles are specified, the leftmost context handle is used as the binding handle. When the first parameter is not a handle and there are no context handles, the procedure uses implicit binding using the ACF attribute [implicit_handle] or [auto_handle].

The Microsoft extensions to the IDL allow the binding handle to be in a position other than the first parameter. The leftmost [in] explicit-handle parameter–whether it is a primitive, programmer-defined, or context handle–is the binding handle. When there are no handle parameters, the procedure uses implicit binding using the ACF attribute [implicit_handle] or [auto_handle].

The following rules apply to both DCE-compatibility (/osf) mode and default mode:

  • Auto-handle binding is used when no ACF is present.
  • Explicit [in] or [in, out] handles for an individual function preempt any implicit binding specified for the interface.
  • Multiple [in] or [in, out] primitive handles are not supported.
  • Multiple [in] or [in, out] explicit context handles are allowed.
  • All programmer-defined handle parameters except the binding-handle parameter are treated as transmissible data.

The following table contains examples and describes how binding handles are assigned in each compiler mode.

Example Description
<pre class="syntax" data-space="preserve"><code>void proc1( void );</code></pre> No explicit handle is specified. The implicit binding handle, specified by [ <a href="/windows/desktop/Midl/implicit-handle">implicit_handle</a>] or [ <a href="/windows/desktop/Midl/auto-handle">auto_handle</a>], is used. When no ACF is present, an auto handle is used.
<pre class="syntax" data-space="preserve"><code>void proc2([in] handle_t H, [in] short s );</code></pre> An explicit handle of type handle_t is specified. The parameter H is the binding handle for the procedure.
<pre class="syntax" data-space="preserve"><code>void proc3([in] short s, [in] handle_t H );</code></pre> The first parameter is not a handle. In default mode, the leftmost handle parameter, H, is the binding handle. In /osf mode, implicit binding is used. An error is reported because the second parameter is expected to be transmissible, and handle_t cannot be transmitted.
<pre class="syntax" data-space="preserve"><code>typedef [handle] short * MY_HDL;void proc1([in] short s, [in] MY_HDL H );</code></pre> The first parameter is not a handle. In default mode, the leftmost handle parameter, H, is the binding handle. The stubs call the user-supplied routines MY_HDL_bind and MY_HDL_unbind. In/osf mode, implicit binding is used. The programmer-defined handle parameter H is treated as transmissible data.
<pre class="syntax" data-space="preserve"><code>Typedef [handle] short * MY_HDL;void proc1([in] MY_HDL H, [in] MY_HDL p );</code></pre> The first parameter is a binding handle. The parameter H is the binding-handle parameter. The second programmer-defined handle parameter is treated as transmissible data.
<pre class="syntax" data-space="preserve"><code>Typedef [context_handle] void * CTXT_HDL;void proc1([in] short s, [in] long l, [in] CTXT_HDL H , [in] char c);</code></pre> The binding handle is a context handle. The parameter H is the binding handle.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。