Generating the Stub Files

After defining the client/server interface, you usually develop your client and server source files, and then use a single makefile to generate the stub and header files and compile and link the client and server applications. However, if this is your first exposure to the distributed computing environment, you may want to invoke the MIDL compiler now to see what MIDL generates before you continue.

The MIDL compiler (MIDL.EXE) is automatically installed when you install the Win32 SDK. Make sure that hello.idl and hello.acf are in the same directory. The following command will generate the header file hello.h, and the client and server stubs, hello_c.c and hello_s.c:

C:\> midl hello.idl
 

Notice that hello.h contains function prototypes for HelloProc and Shutdown, as well as forward declarations for two functions, MIDL_user_allocate and MIDL_user_free. You will provide those two memory management functions in the server application. If data were also being transmitted from the server to the client (via an out parameter) you would also need to provide these two memory management functions in the client application.

Also note the definitions for our global handle variable, hello_IfHandle, and the client and server interface handle names, hello_v1_0_c_ifspec and hello_v1_0_s_ifspec, which the client and server applications will use in run-time calls.

You don't need to do anything with the stub files hello_c.c and hello_s.c.

/*file: hello.h */
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 3.00.06 
/* at Tue Feb 20 11:33:32 1996 */
/* Compiler settings for hello.idl:
    Os, W1, Zp8, env=Win32, ms_ext, c_ext
    error checks: none */
//@@MIDL_FILE_HEADING(  )
#include "rpc.h"
#include "rpcndr.h"
 
#ifndef __hello_h_
#define __hello_h_
 
#ifdef __cplusplus
extern "C"{
#endif 
 
/* Forward Declarations */ 
 
void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void __RPC_FAR * ); 
 
#ifndef __hello_INTERFACE_DEFINED__
#define __hello_INTERFACE_DEFINED__
 
/****************************************
 * Generated header for interface: hello
 * at Tue Feb 20 11:33:32 1996
 * using MIDL 3.00.06
 ****************************************/
/* [implicit_handle][version][uuid] */ 
 
            /* size is 0 */
void HelloProc( 
    /* [string][in] */ unsigned char __RPC_FAR *pszString);
            /* size is 0 */
void Shutdown( void);
extern handle_t hello_IfHandle;
 
extern RPC_IF_HANDLE hello_v1_0_c_ifspec;
extern RPC_IF_HANDLE hello_v1_0_s_ifspec;
#endif /* __hello_INTERFACE_DEFINED__ */
 
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif