equip200,
If you need another program to connect to the running instance of your
program through COM, then you will have quite a bit of work to do.
The first thing you have to do is make sure that whatever object you are
going to make available to the other running program is interoperable with
COM.
Once you do that, when your program runs, you will have to marshal your
interface pointer to the running object table. You can do this by getting
the running object table by calling GetRunningObjectTable through the
P/Invoke layer. This will return to you an IRunningObjectTable
implementation, which is represented in .NET through the
UCOMIRunningObjectTable interface, defined in the
System.Runtime.InteropServices namespace. In .NET 2.0, you should probably
use the IRunningObjectTable interface in the
System.Runtime.InteropServices.ComTypes namespace.
You can then call Register to register your object. You have to pass a
moniker to identify your object. What kind of moniker you create is up to
you, but that's dependent on your application. For example, if you want the
running instance that is hosting a particular file, create a file moniker
(through the CreateFileMoniker function) and pass that to register.
Then, when you want to access the object on the other side, you would
get the running object table again, and call GetObject.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
equip200 said:
On your first QS, I'm trying to have another program access mine trough
COM
or OLE (don't know which does what) but that is the ability the other
program
has.
On the second I have tried to access the other program COM but it does not
have DLL it has EXE. And I could not import into reference. But this is
not
my priority the above is.
It also needs the running instance.(it needs to run the methods of my
program that is already started not on its own , is this what u meant?).
Nicholas Paldino said:
equip200,
Are you trying to have another program access yours through COM, or
are
you trying to access another COM object? Also, if another program is
trying
to access your program through COM, does it need the running instance, or
can it just create a new one?
Depending on your answers, the solutions will be different.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
equip200 said:
I have a third party program that has the ability to control my program
trough ActiveX/COM.
My program is built in c#?
What would I need to do to have the third party program connect to my
program or just execute methods in my program?
IS SOMETHING LIKE THIS THE CORRECT START AND WHATS NEEDED TO FOLLOW?
AB = new ActiveXObject("Bro.method");
Can it be done in c#?
If so, how?
Any examples?
Or links to learn.
Can someone help me with this issue?
THANKS