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

Developing the Server

· 52CE 我爱测

When you create a server program for a distributed application, you must use the header file and server stub that the MIDL compiler generates.

When you create a server program for a distributed application, you must use the header file and server stub that the MIDL compiler generates. For details, see Developing the Interface. Include the header file in your server C program file. Compile the server stub with the C source files that compose your application. Link the resulting object files together with the import library. This process is illustrated in the following diagram.

process of creating a server program for a distributed application

As you can see from the example in the illustration, a MIDL file called MyApp.idl was used to define the interface. The MIDL compiler used MyApp.idl to produce MyApp_s.c and MyApp.h. It also produces a C source file for the client stub, but that is not relevant to this particular discussion. The C source file for the server program (in this case, Mysrvr.c) must include the file Myapp.h. It will also need to include the files Rpc.h and Rpcndr.h.

The server application was developed in two files, Mysrvr.c and Rprocs.c. The file Mysrvr.c contains the functions necessary for getting the server program up and running. The remote procedures that the server program offers are contained in the file Rprocs.c.

The files Mysrvr.c and Rprocs.c were compiled together with Myapp_s.c to produce object files. The object files were then linked with the RPC run-time library, and any other libraries that they might need. The result is an executable server program named Mysrvr.exe.

If you do not compile your IDL file in Open Software Foundation (OSF) compatibility mode (/osf), your server program must provide a function for allocating memory and a function for deallocating it. For Windows 2000 and later versions of Windows, 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)

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

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