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

Length, Size, and Directional Attributes

· 52CE 我爱测

In passing arrays between the client and the server, the size-related attributes \ max_is\ and \ size_is\ determine how many array elements the server stub allocates.

In passing arrays between the client and the server, the size-related attributes [max_is] and [size_is] determine how many array elements the server stub allocates. The length-related attributes [length_is], [first_is], and [last_is] determine how many elements are transmitted to both the server and the client.

Different directional attributes can be applied to parameters. However, some combinations of directional attributes can cause errors. As an example, suppose you are writing an interface that specifies a procedure with two parameters, an array, and the transmitted length of the array. The term dir_attr refers to the directional attribute applied to the parameter as:

Proc1(
    [dir_attr] short *plength;
    [dir_attr, length_is(pLength)] short array[MAX_SIZE]);

The MIDL compiler behavior for each combination of directional attributes is described in the following table.

Array Length parameter Stub actions during call from client to server Stub actions on return from server to client
[in] [in] Transmit the length and the number of elements indicated by the parameter. No data transmitted.
[in] [out] Not legal; MIDL compiler error. Not legal; MIDL compiler error.
[in] [in, out] Transmit the length and the number of elements indicated by the length parameter. Transmit the length only.
[out] [in] Transmit the length. If array size is fixed, allocate the array size on the server, but transmit no elements. If array size is not bound, not legal: MIDL compiler error. Transmit the number of elements indicated by the length. Note that the length can be changed and can have a different value from the value on the client. Do not transmit the length.
[out] [out] Allocate space for the length parameter on the server but do not transmit the parameter. If the array size is fixed, allocate the array size on the server, but transmit no elements. If array size is not fixed, not legal: MIDL compiler error. Transmit the length and the number of elements indicated by the length as set by the server application.
[out] [in, out] Transmit the length parameter. If the array size is bound, allocate the array size on the server, but transmit no elements. If array size is not bound, not legal: MIDL compiler error. Transmit the length. Transmit the number of array elements indicated by the length.
[in, out] [in] Transmit the length and the number of elements indicated by the parameter. Do not transmit the length. Transmit the number of elements indicated by the length. Note that the length can be changed and can have a different value from the original value on the client.
[in, out] [out] Not legal; MIDL compiler error. Not legal; MIDL compiler error.
[in, out] [in, out] Transmit the length and the number of elements indicated by the parameter. Transmit the length and the number of elements indicated by the parameter.

In general, you should not modify the length or size parameters on the server side. If you change the length parameter, you can orphan memory. For more information, see Memory Orphaning.

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)

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

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