S
Scott McPhillips [MVP]
I am developing a COM Addin for Word (in C++ with ATL). The basics are
working: Word starts me and I can do things on events from Word OK. But
I also need to access Word objects at times when there is no event
coming in.
A periodic timer call would be great, but there does not seem to be one
in the Word interface.
So I am trying a secondary thread within my addin. If it calls
CoCreateInstance that creates a new instance of Word, not the instance I
need access to. So in desparation I tried copying the
Word::_Application CComPtr from main thread to the secondary thread. It
seems to work with some simple tests but I don't know if it is safe.
- Is there some way, like a timer, I can get Word to call me periodically?
- Is there some way to get a pointer to the currently running
Word::_Application object from a secondary (but in-process) thread?
- Or a way to safely use the pointer I copied from the main thread?
working: Word starts me and I can do things on events from Word OK. But
I also need to access Word objects at times when there is no event
coming in.
A periodic timer call would be great, but there does not seem to be one
in the Word interface.
So I am trying a secondary thread within my addin. If it calls
CoCreateInstance that creates a new instance of Word, not the instance I
need access to. So in desparation I tried copying the
Word::_Application CComPtr from main thread to the secondary thread. It
seems to work with some simple tests but I don't know if it is safe.
- Is there some way, like a timer, I can get Word to call me periodically?
- Is there some way to get a pointer to the currently running
Word::_Application object from a secondary (but in-process) thread?
- Or a way to safely use the pointer I copied from the main thread?