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

Conformant Arrays

· 52CE 我爱测

The size of a conformant array can vary or conform each time the client passes it to a remote procedure on the server.

The size of a conformant array can vary or conform each time the client passes it to a remote procedure on the server. The interface definition in the application's MIDL file enables the client to specify the size of the array each time it invokes the remote procedure. Use empty square brackets ([ ]) or an asterisk in the square brackets ([*]) in the array definition to indicate a conformant array.

The following sample contains the definition of a remote procedure in an interface in a MIDL file. The client specifies the size of the array that it passes to the server by the parameter arraySize.

[
    /*Attributes are defined here. */
]
interface MyInterface
{
    MyRemoteProc(
         long lArraySize,
         [size_is(lArraySize)] char achArray[*]
    );

    /* Other interface procedures are defined here. */
}

The interface definition uses the MIDL attribute [size_is] to specify the size of the array that the client passes to the server. If you would rather indicate the maximum value of the array's index numbers, use the [max_is] attribute instead. For more information on these MIDL attributes, see Array Attributes.

The following code fragment illustrates how a client might invoke the remote procedure defined in the preceding MIDL file.

long lArrayLength = 20;
char achCharArray[20], achAnotherCharArray[200];

// Code to store 20 chars in achCharArray goes here.

MyRemoteProc(
    lArrayLength ,
    achCharArray);

lArrayLength = 200;

// Code to store 200 chars in achAnotherCharArray goes here.

MyRemoteProc(
    lArrayLength ,
    achAnotherCharArray);

This fragment calls the remote procedure MyRemoteProc twice. On the first invocation it passes an array of 20 elements. On the second call, the client passes an array of 200 elements.

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)

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

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