Samples
The Win32 SDK includes sample programs that demonstrate a variety of RPC concepts, as follows:
-
CALLBACK demonstrates use of the callback attribute.
-
CLUUID demonstrates use of the client object UUID to enable a client to select among multiple implementations of a remote procedure.
-
DATA directory contains four programs: DUNION illustrates discriminated (nonencapsulated) unions; INOUT demonstrates in, out parameters; REPAS demonstrates the represent_as attribute; XMIT demonstrates the transmit_as attribute.
-
DICT is a remote splay tree-based dictionary program that uses the implicit_handle, context_handle, in, and out attributes.
-
DOCTOR is an RPC psychotherapy application that demonstrates arrays, strings, and the size_is attribute.
-
DYNEPT demonstrates a client application managing its connection to the server through dynamic endpoints.
-
DYNOUT demonstrates how to allocate memory at a server for an n-byte object and pass it back to the client as an [out]-only parameter. The client then frees the memory. This technique allows the stub to call the server without knowing in advance how much data will be returned.
-
HANDLES directory contains three programs, AUTO, CXHNDL, USRDEF, which demonstrate auto_handle, context_handle, and generic (user-defined) handles, respectively.
-
HELLO is a client/server implementation of "Hello, world."
-
INTEROP demonstrates portability between OSF DCE and Microsoft® RPC.
-
MANDEL is a distributed fractal drawing program. It uses ref pointers, implicit_handle attribute, and handle_t primitive types.
-
NS directory contains the NHELLO program, which demonstrates name service usage. The CDS directory contains the files that describe the gateway protocol to the DCE Cell Directory Service (CDS).
-
OBJECT directory contains two programs that demonstrate OLE custom interfaces. CALLAS uses the call_as attribute to transmit a nonremotable interface. OHELLO demonstrates correct reference counting and shutdown behavior for a multiple-use local server. OHELLO also demostrates how to use the Win32 registry functions to install a local server and a proxy DLL in the registry.
-
PICKLE directory contains two programs: PICKLP demonstrates data procedure serialization; PICKLT demonstrates data type serialization; both programs use the encode and decode attributes.
-
PIPES demonstrates the use of the pipe type constructor.
-
RPCSSM demonstrates the rpcss memory management model.
-
RPCSVC demonstrates the implementation of a Windows NT™ service with RPC.
-
STROUT demonstrates how to allocate memory at a server for a two-dimensional object (an array of pointers) and pass it back to the client as an [out]-only parameter. The client then frees the memory. This technique allows the stub to call the server without knowing in advance how much data will be returned.
This program also allows the user to compile either for UNICODE or ANSI.
-
WHELLO is a client/server "Hello, World" for 16-bit Windows. Client and server applications can also run on the same Windows NT workstation.
-
YIELD demonstrates use of the RpcWinSetYieldInfo API function to prevent a 16-bit Windows distributed application from blocking during lengthy remote procedure calls.
You can browse through most of these files in the Win32 SDK on-line help book Code Samples | RPC. All of the source files and makefiles for these programs are located in the Win32 SDK directory mstools\samples\rpc.