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>