Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Any ideas on gettin a IDispatch interface from Remote Computer?

Any ideas on gettin a IDispatch interface from Remote Computer?

Scheduled Pinned Locked Moved COM
testingtoolshelptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FearlessBurner
    wrote on last edited by
    #1

    I have wrote a SDI windows application(MyApp.exe) with an automation IDispatch interface for remote control. My problem is that I want to connect my client program to a running instance of MyApp.exe, rather than start up a new instance. I succeeded doing this by changing the orignal initialisation pIMyApp = new IMyApp; pIMyApp->CreateDispatch( "MyApp.Document" ); to the lines pIMyApp = new IMyApp; CLSID clsid; if ( CLSIDFromProgID( OLESTR( "MyApp.Document" ), &clsid)==NOERROR) { IUnknown *pUnknown=NULL; HRESULT hr=GetActiveObject(clsid,NULL,&pUnknown); if ( SUCCEEDED(hr) ) { IDispatch *pIDispatch=NULL; hr=pUnknown->QueryInterface(IID_IDispatch,(void **)&pIDispatch); if (SUCCEEDED(hr) ) { pIMyApp->AttachDispatch(pIDispatch,FALSE ); bInitialised = true; } pUnknown->Release(); } } which attaaches pIMyApp interface pointer to the running instance of MyApp.exe (the IMyApp is registered in the Running-Object-Table) on my own computer. I want be able to do the same on a remote computer. Is it possible to get apply GetActiveObject() to a remote instsance? The MS Knowledge base has a over complicated example of achieving this for a program called ROTMONK.EXE which seems over complicated to me. As I missing something? Does anyone know of a straightforward way of achieving a connection to a runing instance on a remote computer? Or more importantly, does anyone have any suggestions of a better way of achieving my aim?

    V 1 Reply Last reply
    0
    • F FearlessBurner

      I have wrote a SDI windows application(MyApp.exe) with an automation IDispatch interface for remote control. My problem is that I want to connect my client program to a running instance of MyApp.exe, rather than start up a new instance. I succeeded doing this by changing the orignal initialisation pIMyApp = new IMyApp; pIMyApp->CreateDispatch( "MyApp.Document" ); to the lines pIMyApp = new IMyApp; CLSID clsid; if ( CLSIDFromProgID( OLESTR( "MyApp.Document" ), &clsid)==NOERROR) { IUnknown *pUnknown=NULL; HRESULT hr=GetActiveObject(clsid,NULL,&pUnknown); if ( SUCCEEDED(hr) ) { IDispatch *pIDispatch=NULL; hr=pUnknown->QueryInterface(IID_IDispatch,(void **)&pIDispatch); if (SUCCEEDED(hr) ) { pIMyApp->AttachDispatch(pIDispatch,FALSE ); bInitialised = true; } pUnknown->Release(); } } which attaaches pIMyApp interface pointer to the running instance of MyApp.exe (the IMyApp is registered in the Running-Object-Table) on my own computer. I want be able to do the same on a remote computer. Is it possible to get apply GetActiveObject() to a remote instsance? The MS Knowledge base has a over complicated example of achieving this for a program called ROTMONK.EXE which seems over complicated to me. As I missing something? Does anyone know of a straightforward way of achieving a connection to a runing instance on a remote computer? Or more importantly, does anyone have any suggestions of a better way of achieving my aim?

      V Offline
      V Offline
      Vi2
      wrote on last edited by
      #2

      GetActiveObject cannot be applicable by ROTMONK.EXE's manner because the moniker by which the object is registered in ROT is really the non-bindable moniker. With best wishes, Vita

      F 1 Reply Last reply
      0
      • V Vi2

        GetActiveObject cannot be applicable by ROTMONK.EXE's manner because the moniker by which the object is registered in ROT is really the non-bindable moniker. With best wishes, Vita

        F Offline
        F Offline
        FearlessBurner
        wrote on last edited by
        #3

        Thanks for the comment Vita.:) I wasn't completely sure without trying it whether I would be able to use BindToObject() to attach to the process but I won't even try now. Anyway, I have reflectioning further on this, and guess that what I am trying to do is not strictly necessary and can hopefully achieve what I need using a slightly different approach. If I use the pIMyApp->CreateDispatch( "InterfaceName" ) function to get the interfaces that I need then that should suffice, as long as the required interfaces all connect to just one singleton instance of my exe automation server. As per normal apps, the important thing is the data, which must be common so that the interfaces can access it. I am, of course, greatful for any help that I might receive.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups