Solved

RPC / SERVICE SAMPLE CODE - URGENT

Posted on 2000-03-14
5
470 Views
Last Modified: 2013-12-03
Experts,
i can't download the source code for rpc and service programs from the msdn,
i need a simple code (a hello world rpc/service applications), it's necessary the idl interface too.

thanks
0
Comment
Question by:cvillacrizv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 2618305
Run server srv.exe
Run
 cli.exe localhost "Hello, World!"

To shutdown server,

   cli.exe localhost SHUTDOWN

--- make.bat
-----------------------------
midl hello.idl
cl srv.c hello_s.c rpcrt4.lib
cl cli.c hello_c.c rpcrt4.lib


--- cli.c
-----------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "hello.h"

void main(int argc, char *argv[])
{
    unsigned char *pszStringBinding;

    if (argc != 3)
    {
        printf("Usage: %s hostname string-to-print\n", argv[0]);
        exit(1);
    }
    RpcStringBindingCompose(NULL, "ncacn_ip_tcp", argv[1], "8000", NULL,
&pszStringBinding);
    RpcBindingFromStringBinding(pszStringBinding, &hello_IfHandle);
    if (strcmp(argv[2], "SHUTDOWN")) HelloProc(argv[2]);
    else Shutdown();
    RpcStringFree(&pszStringBinding);
    RpcBindingFree(&hello_IfHandle);
}

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);
}

--------- srv.c
-----------------------------

#include <stdlib.h>
#include <stdio.h>
#include "hello.h"

void HelloProc(const unsigned char *pszString)
{
    printf("%s\n", pszString);
}

void Shutdown(void)
{
    RpcMgmtStopServerListening(NULL);
    RpcServerUnregisterIf(NULL, NULL, FALSE);
}

void main(int argc, char * argv[])
{
    RpcServerUseProtseqEp("ncacn_ip_tcp", 20, "8000", NULL);
    RpcServerRegisterIf(hello_v1_0_s_ifspec, NULL, NULL);
    RpcServerListen(1, 20, FALSE);
}

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);
}

--------hello.acf
-----------------------------
[
  implicit_handle(handle_t hello_IfHandle)
]
interface hello
{
}


--------hello.idl
-----------------------------
[
  uuid (6fdd2ce0-0985-11cf-87c3-00403321bfac),
  version(1.0)
]
interface hello
{
  void HelloProc([in, string] const unsigned char *pszString);
  void Shutdown(void);
}

0
 
LVL 1

Author Comment

by:cvillacrizv
ID: 2620196
Thanks NickRepin i have compiled and  tested the samples and it works!

Finally, i need this source to be a nt service, please i need some simple guide to convert the rpc sample into a nt service/rpc sample...
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2621595
Sorry, that is totally different from your original question.

I'm afraid, when I answer to your new question, you'll ask me again about something else.



0
 
LVL 1

Author Comment

by:cvillacrizv
ID: 2621635
NickRepin,
i' very sorry, i'll try to be more specific in the future.

Thanks for your help
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2621701
Thank you,

but the service/rpc sample is really several times harder than just rpc.
I have no time at the moment to write it for you. Sorry.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question