DUNIONP.C
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:2k
源码类别:
Windows编程
开发平台:
Visual C++
- /****************************************************************************
- Microsoft RPC Version 2.0
- Copyright Microsoft Corp. 1992, 1993, 1994- 1996
- Discriminated Union Example
- FILE: unionp.c
- PURPOSE: Remote procedures that are linked with the server
- side of RPC distributed application
- FUNCTIONS: UnionParamProc() - union, discriminant are parameters
- UnionStructProc() - union, discriminant in structure
- COMMENTS: This distributed application illustrates distriminated
- union.
- ****************************************************************************/
- #include <stdlib.h>
- #include <stdio.h>
- #include "dunion.h" // header file generated by MIDL compiler
- void UnionParamProc(DISCRIM_UNION_PARAM_TYPE *up,
- short sDiscrim)
- {
- printf("sDiscrim = %d, data = ", sDiscrim);
- switch(sDiscrim) {
- case 0:
- printf("short %dn", up->sVal);
- break;
- case 1:
- printf("float %fn", up->fVal);
- break;
- case 2:
- printf("char %cn", up->chVal);
- break;
- default:
- printf("invalidn");
- break;
- }
- }
- void UnionStructProc(DISCRIM_UNION_STRUCT_TYPE *u)
- {
- printf("sDiscrim = %d, data = ", u->sDiscrim);
- switch(u->sDiscrim) {
- case 0:
- printf("short %dn", u->u.sVal);
- break;
- case 1:
- printf("float %fn", u->u.fVal);
- break;
- case 2:
- printf("char %cn", u->u.chVal);
- break;
- default:
- printf("invalidn");
- break;
- }
- }
- void Shutdown(void)
- {
- RPC_STATUS status;
- printf("Calling RpcMgmtStopServerListeningn");
- status = RpcMgmtStopServerListening(NULL);
- printf("RpcMgmtStopServerListening returned: 0x%xn", status);
- if (status) {
- exit(status);
- }
- printf("Calling RpcServerUnregisterIfn");
- status = RpcServerUnregisterIf(NULL, NULL, FALSE);
- printf("RpcServerUnregisterIf returned 0x%xn", status);
- if (status) {
- exit(status);
- }
- }
- /* end file dunionp.c */