check if com api is still available

H

Hermann Maier

Hi,

i am using the com api of a program and if this program is shut down and
my program calls a method of the api, it crashs. that means, i need to
check, if the com server is still available, before i can call for it.

i already have a solution for this problem and it works quiet well, but
i think, it is not that nice. my solution works that way, that i create
a new thread, call a method of my com object and write back a value in
my main object. that means, if the method call fails, only the thread
crashes, not my whole program. if the method call succeeds, i can write
back my value in my main object and so i know, if the thread crashes or
not. the thing that is not nice about it is, that the thread remains in
the memory.

perhaps there is a possibility to kill this thread, but i would prefer a
solution that is more clean from the beginning. perhaps there is a
windows event that can tell me, wenn the other application, that hosts
the com server, is closed or perhaps i can do something with the guid of
the com server, maybe there is a call where i can check, if a certain
com server is available.

thank you for your help, Maier.
 
N

Neil Hodgson

Hermann Maier:
i am using the com api of a program and if this program is shut down and
my program calls a method of the api, it crashs. that means, i need to
check, if the com server is still available, before i can call for it.

The server should not shut down while clients have outstanding
references to objects within it.
but i would prefer a
solution that is more clean from the beginning. perhaps there is a
windows event that can tell me, wenn the other application, that hosts
the com server, is closed or perhaps i can do something with the guid of
the com server, maybe there is a call where i can check, if a certain
com server is available.

All running COM servers should be in the "Running Object Table"
(ROT). If you search the net for this term you will find code that can
show what is in the ROT, so there must be an API.

Neil
 
C

Chris Mellon

Hermann Maier:


The server should not shut down while clients have outstanding
references to objects within it.

The Excel COM object has this behavior - if you call the Quit() method
or (if you're controlling an interactive instance) the excel window is
closed, further calls to the COM object will throw errors. I couldn't
find a solution to this other than to just make sure you didn't do
that. However, I didn't know about the ROT and maybe that will work.
 
T

Tim Roberts

Neil Hodgson said:
All running COM servers should be in the "Running Object Table"
(ROT). If you search the net for this term you will find code that can
show what is in the ROT, so there must be an API.

If only. The Microsoft Office applications seem to be the only ones in the
world that use the ROT.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top