znappa,
In order to do this, you are going to have to check the running object
table of the machine. The running object table is a list of com servers
that are identified with a unique moniker (name).
In order to get the running object table, you will have to define the
GetRunningObjectTable function so that you can call it through the P/Invoke
layer. Once you call that, it should return (through a parameter) an
implementation of UCOMIRunningObjectTable, an interface found in the
System.Runtime.InteropServices namespace. You can then call GetObject on
that interface to get an object based on its name.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
(E-Mail Removed)
"znappa" <(E-Mail Removed)> wrote in message
news:ED406A16-7627-4716-95F9-(E-Mail Removed)...
> Hi.
> I would like to create an instance of a COM server from C# code.
> I now use the System.Runtime.InteropServices.Marshal.GetActiveObject()
> function to get the running instance (but this implies that there is an
> instance running). But I would like to check (at the start of my code)
> wether
> there is a running instance and if not, start one. I'm not to familiar
> with
> COM, so "best practise" hints would be nice!