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

Developing the Client

· 52CE 我爱测

Developing an RPC client program is similar to developing the server program. For information on developing an RPC server program, see Developing the Server.

Developing an RPC client program is similar to developing the server program. For information on developing an RPC server program, see Developing the Server.

As in server development, your client program must include the header file that the MIDL compiler generates from your .idl file. The MIDL compiler also generates a C source file containing the client stub. You must compile this C source file and link it to your client program. (In addition, the MIDL compiler generates a C source file containing the server stub, but that is not relevant to this discussion.)

In addition to compiling and linking the client stub with your program files, you must link the import library (and any other libraries your client program needs) to your client program. The process of creating an RPC client program is illustrated in the following diagram.

process of creating a client program for a distributed application

The example in the preceding illustration demonstrates the creation of an RPC client program called MyClnt.exe. The first step is to define the interface in the file MyApp.idl. The MIDL compiler uses MyApp.idl to generate the file MyApp_c.c, which contains the client stub. It also generates the file MyApp.h, which the client program must include. The client program will also need to include the files RPC.h and RPCNDR.h.

The client program itself is created in the file MyClnt.c. In a real project, the client program would typically be composed of several C source files. All of them would need to be compiled and linked together. However, this example uses only one file for simplicity.

The files MyClnt.c and MyApp_c.c are compiled and linked together with the RPC run-time library, and any other libraries that the client program needs. The result is an executable client program named MyClnt.exe.

If you do not compile your IDL file in OSF compatibility mode (/osf), your client program must provide a function for allocating memory and a function for deallocating it. For Windows 2000 and later versions, the recommended mode is /Oicf. For details, see How Memory Is Allocated and Deallocated, and Pointers and Memory Allocation.

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)

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

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