Any ideas on gettin a IDispatch interface from Remote Computer?
-
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 linespIMyApp = 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? -
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 linespIMyApp = 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? -
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
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.