⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rpcfact_c.cpp

📁 一个RPC例子
💻 CPP
字号:
/* this ALWAYS GENERATED file contains the RPC client stubs */


/* File created by MIDL compiler version 5.01.0164 */
/* at Wed Dec 05 09:20:26 2007
 */
/* Compiler settings for Rpcfact.idl:
    Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext
    error checks: allocation ref bounds_check enum stub_data 
*/
//@@MIDL_FILE_HEADING(  )

#include <string.h>
#if defined( _ALPHA_ )
#include <stdarg.h>
#endif

//#include "Rpcfact.h"
//////////////////////////////////////////////////////////////////////////
// File: RpcFact_c.c

  #include <windows.h>

  #include <iostream.h>

  #include <rpc.h>
#include "stdio.h"

  #include <stdlib.h>

  #include "Rpcfact.h"

  #include "memstub.h"
//////////////////////////////////////////////////////////////////////////

#define TYPE_FORMAT_STRING_SIZE   3                                 
#define PROC_FORMAT_STRING_SIZE   5                                 

typedef struct _MIDL_TYPE_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ TYPE_FORMAT_STRING_SIZE ];
    } MIDL_TYPE_FORMAT_STRING;

typedef struct _MIDL_PROC_FORMAT_STRING
    {
    short          Pad;
    unsigned char  Format[ PROC_FORMAT_STRING_SIZE ];
    } MIDL_PROC_FORMAT_STRING;


extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;

/* Standard interface: rpcfactorial, ver. 1.0,
   GUID={0xC16F6562,0x520D,0x11D0,{0xB3,0x38,0x44,0x45,0x53,0x54,0x00,0x00}} */


static RPC_PROTSEQ_ENDPOINT __RpcProtseqEndpoint[] = 
    {
    {(unsigned char *) "ncalrpc", (unsigned char *) "myFactorial"}
    };


static const RPC_CLIENT_INTERFACE rpcfactorial___RpcClientInterface =
    {
    sizeof(RPC_CLIENT_INTERFACE),
    {{0xC16F6562,0x520D,0x11D0,{0xB3,0x38,0x44,0x45,0x53,0x54,0x00,0x00}},{1,0}},
    {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
    0,
    1,
    __RpcProtseqEndpoint,
    0,
    0,
    0
    };
RPC_IF_HANDLE rpcfactorial_v1_0_c_ifspec = (RPC_IF_HANDLE)& rpcfactorial___RpcClientInterface;

extern const MIDL_STUB_DESC rpcfactorial_StubDesc;

static RPC_BINDING_HANDLE rpcfactorial__MIDL_AutoBindHandle;


long RpcFactorial( 
    /* [in] */ long nVal)
{

    long _RetVal;
    
    RPC_MESSAGE _RpcMessage;
    
    MIDL_STUB_MESSAGE _StubMsg;
    
    RpcTryFinally
        {
        NdrClientInitializeNew(
                          ( PRPC_MESSAGE  )&_RpcMessage,
                          ( PMIDL_STUB_MESSAGE  )&_StubMsg,
                          ( PMIDL_STUB_DESC  )&rpcfactorial_StubDesc,
                          0);
        
        
        
        _StubMsg.BufferLength = 4U;
        NdrNsGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, rpcfactorial__MIDL_AutoBindHandle );
        
        (*(( long __RPC_FAR * )_StubMsg.Buffer))++ ;
        (*(( long __RPC_FAR * )_StubMsg.Buffer))= nVal;
        NdrNsSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer, (RPC_BINDING_HANDLE __RPC_FAR *) &rpcfactorial__MIDL_AutoBindHandle );
        
        if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
            NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
        
        _RetVal = (*(( long __RPC_FAR * )_StubMsg.Buffer))++;
        
        }
    RpcFinally
        {
        NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
        
        }
    RpcEndFinally
    
    return _RetVal;
}


static const MIDL_STUB_DESC rpcfactorial_StubDesc = 
    {
    (void __RPC_FAR *)& rpcfactorial___RpcClientInterface,
    MIDL_user_allocate,
    MIDL_user_free,
    &rpcfactorial__MIDL_AutoBindHandle,
    0,
    0,
    0,
    0,
    __MIDL_TypeFormatString.Format,
    1, /* -error bounds_check flag */
    0x10001, /* Ndr library version */
    0,
    0x50100a4, /* MIDL Version 5.1.164 */
    0,
    0,
    0,  /* notify & notify_flag routine table */
    1,  /* Flags */
    0,  /* Reserved3 */
    0,  /* Reserved4 */
    0   /* Reserved5 */
    };

#if !defined(__RPC_WIN32__)
#error  Invalid build platform for this stub.
#endif

static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
    {
        0,
        {
			0x4e,		/* FC_IN_PARAM_BASETYPE */
			0x8,		/* FC_LONG */
/*  2 */	0x53,		/* FC_RETURN_PARAM_BASETYPE */
			0x8,		/* FC_LONG */

			0x0
        }
    };

static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
    {
        0,
        {
			NdrFcShort( 0x0 ),	/* 0 */

			0x0
        }
    };



  main()

  {

      long nVal;
  
      cout<<"Calling RPC Factorial"<<endl;

// 	  unsigned char * szStringBinding;
// 
// 	  RPC_STATUS   status;   
// 	  unsigned char * str= (unsigned   char*)("ncacn_ip_tcp");
// 	  unsigned char * IP=(unsigned   char*)("192.168.1.222");
// 
// 	  
// 	  status   =   RpcStringBindingCompose(NULL, str,IP, NULL,   NULL,   &szStringBinding);   
// 	  if   (status) 
// 	  {
// 		  cout<<"Error in RpcStringBindingCompose "<<endl;
// 		  return   0; 
// 	  }
// 	  status   =   RpcBindingFromStringBinding(   szStringBinding,   &rpcfactorial_v1_0_c_ifspec);  
      
	  nVal = RpcFactorial(5);

      cout<<"RpcFact returns: "<<nVal<<endl;

	  getchar();
      return 0;

  }

  // end File RpcFact_c.c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -