CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011
    Posts
    23

    Question link to RPC in a DLL from a non-RPC App

    I have a program that I have written, and it is complex enough I don't want to convert it from a standard MFC app to an RPC enabled MFC app by creating the framework and porting all of my code over (very tedious and highly prone to failure). I want to write an RPC enabled DLL to handle the remote calls (commands). I can do this, right? Create an RPC DLL and link to it with a non RPC application and pass commands from the non RPC app to the RPC DLL and have the RPC DLL issue the remote commands?

    Thanks in advance for any and all help you can provide . . . I am open to suggestions from anyone as to how I can have my currently non-RPC App perform RPC tasks.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: link to RPC in a DLL from a non-RPC App

    You'd better try this approach with some simplistic app first. And yes, in theory you can do that what you explained above. The expected logic is as follows (supposing you implement COM out-of-proc server):
    • Your main app exposes its internal functionality to the dll, most probably by means of a set of interfaces which pointers are passed to the RPC dll during its initialization on post load phase
    • In its turn the dll exposes to main app some interface that would be called in case the exe has been launched with /embedded, /regserver or /unregserver command arguments
    • On /regserver the dll must register the app as out-of-proc server along with all its co-classes
    • On /unregserver it should unregister the server co-classes
    • On /embedded it should start a main COM server message loop and register the server interfaces in ROT
    • On calling COM interface methods the dll uses internal interfaces obtained on initialization phase
    Nothing special, just a tedious and thorough piece of work, with lots of traps and pitfalls waiting on you.

    BTW, all this can be done inside the app itself, which even would make the things much simpler.
    Last edited by Igor Vartanov; December 9th, 2011 at 04:57 AM.
    Best regards,
    Igor

  3. #3
    Join Date
    Oct 2011
    Posts
    23

    Re: link to RPC in a DLL from a non-RPC App

    "BTW, all this can be done inside the app itself, which even would make the things much simpler. "

    How can I do this in the app? I would need to convert the app to RPC/COM enabled wouldn't I? Is that possible? Or do I have to recreate the project in the desired format, and port all of the code across? I am all for simpler . . . Please explain, if you would, I would really appreciate it. Thanks again.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: link to RPC in a DLL from a non-RPC App

    I would need to convert the app to RPC/COM enabled wouldn't I?
    I'd say, it would be dual app, like MFC server you mentioned before.

    I'd recommend you to implement a couple of ATL COM EXE servers, read through the sources, make few client apps, and play with the servers/clients a little. Sorry, at the moment you're not prepared for discussing details, I bet. BTW, this step is mandatory, disregarding the way you take later.

    The server WinMain would merge properly with your exe main. And all the COM stuff should be added of course.
    Last edited by Igor Vartanov; December 9th, 2011 at 05:45 AM.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured