Re: Using GetActiveObject of OLEAUT32.DLL

Georg Ragaller <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <LISTSERV%[email protected]>
Try this:

<snip>
...
    // Operation unavailable.
    public static final int MK_E_UNAVAILABLE   = 0x800401E3;
...

            IUnknown    iunk      = null;

            try
            {
                iunk = OleAut32.GetActiveObject("Word.Application");
            }
            catch (COMException ex)
            {
                if (MK_E_UNAVAILABLE != ex.hresult)
                {
                    throw ex;
                }
            }

            DispatchPtr component = null;

            //--- did we get a running instance?
            if (null != iunk)
            {
                //--- retrieve the dispatch interface
                component = (DispatchPtr) iunk.queryInterface
(DispatchPtr.class);

            }
            else
            {
                //--- create a new instance
                component = new DispatchPtr("Word.Application");
            }
</snip>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.