You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
4.0 KiB
136 lines
4.0 KiB
//+-------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
//
|
|
// Copyright (C) Microsoft Corporation, 1997 - 1999
|
|
//
|
|
// File: drtc.cxx
|
|
//
|
|
//--------------------------------------------------------------------------
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include "drt.h" // header file generated by MIDL compiler
|
|
|
|
void __cdecl main(int argc, char **argv)
|
|
{
|
|
unsigned char * pszString = (unsigned char *)"drt";
|
|
WCHAR * pszEntryName = L"/.:/drtsrv_01";
|
|
WCHAR * pszGrpEntryName1 = L"/.:/drtgrp_01";
|
|
WCHAR * pszPrfEntryName1 = L"/.:/drtprf_01";
|
|
WCHAR * pszStrBinding = NULL;
|
|
RPC_NS_HANDLE hdrt;
|
|
RPC_BINDING_HANDLE bhdrt;
|
|
RPC_IF_ID ifid;
|
|
unsigned long fNameSyntaxType = RPC_C_NS_SYNTAX_DEFAULT;
|
|
RPC_STATUS status;
|
|
unsigned long ulCode;
|
|
short fSuccess = 0;
|
|
short fContinue = 1;
|
|
short i;
|
|
WCHAR *pMemberName;
|
|
WCHAR *pAnnotation;
|
|
ULONG dwPriority = 0;
|
|
|
|
RpcTryExcept {
|
|
status = RpcNsBindingImportBegin(fNameSyntaxType,
|
|
pszEntryName,
|
|
drtsrv_01_v1_0_c_ifspec,
|
|
NULL,
|
|
&hdrt);
|
|
printf("RpcNsBindingImportBegin returned 0x%x\n", status);
|
|
}
|
|
RpcExcept(1) {
|
|
ulCode = RpcExceptionCode();
|
|
printf("RPC Runtime raised exception 0x%x\n", ulCode);
|
|
fContinue = 0;
|
|
}
|
|
RpcEndExcept
|
|
|
|
if ( status != RPC_S_OK )
|
|
fContinue = 0;
|
|
|
|
/* The loop is present because the name service may contain "stale" */
|
|
/* and unusable binding handlers. This is part of the DCE design. */
|
|
while( fContinue )
|
|
{
|
|
status = RpcNsBindingImportNext(hdrt,
|
|
&bhdrt);
|
|
printf("RpcNsBindingImportNext returned 0x%x\n", status);
|
|
|
|
if ( (status == RPC_S_NO_MORE_BINDINGS) ||
|
|
(status == RPC_S_NAME_SERVICE_UNAVAILABLE ) )
|
|
break;
|
|
|
|
if (status != RPC_S_OK)
|
|
continue;
|
|
|
|
RpcBindingToStringBinding( bhdrt, &pszStrBinding );
|
|
printf("StringBinding: %s\n", pszStrBinding );
|
|
RpcStringFree(&pszStrBinding);
|
|
|
|
RpcTryExcept {
|
|
printf("Calling remote procedure HelloProc with string %s\n",
|
|
pszString);
|
|
HelloProc(bhdrt, pszString);
|
|
fContinue = 0;
|
|
fSuccess = 1;
|
|
}
|
|
RpcExcept(1) {
|
|
ulCode = RpcExceptionCode();
|
|
printf("RPC Runtime raised exception 0x%x\n", ulCode);
|
|
status = RpcBindingFree(&bhdrt);
|
|
printf("RpcBindingFree returned 0x%x\n", status);
|
|
fContinue = 1;
|
|
}
|
|
RpcEndExcept
|
|
|
|
}
|
|
|
|
RpcTryExcept {
|
|
status = RpcNsBindingImportDone(&hdrt);
|
|
printf("RpcNsBindingImportDone returned 0x%x\n", status);
|
|
}
|
|
RpcExcept(1) {
|
|
ulCode = RpcExceptionCode();
|
|
printf("RPC Runtime raised exception 0x%x\n", ulCode);
|
|
fContinue = 0;
|
|
}
|
|
RpcEndExcept
|
|
|
|
if ( fSuccess )
|
|
{
|
|
RpcTryExcept {
|
|
Shutdown(bhdrt); // Shutdown is a remote procedure
|
|
}
|
|
RpcExcept(1) {
|
|
ulCode = RpcExceptionCode();
|
|
printf("RPC runtime raised exception 0x%x\n", ulCode);
|
|
}
|
|
RpcEndExcept
|
|
|
|
status = RpcBindingFree(&bhdrt);
|
|
printf("RpcBindingFree returned 0x%x\n", status);
|
|
}
|
|
|
|
exit(0);
|
|
|
|
} // end main()
|
|
|
|
|
|
/*********************************************************************/
|
|
/* MIDL allocate and free */
|
|
/*********************************************************************/
|
|
|
|
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
|
|
{
|
|
return(malloc(len));
|
|
}
|
|
|
|
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
|
|
{
|
|
free(ptr);
|
|
}
|
|
|
|
/* end file drtc.c */
|