Hi Marcus,
I don't think you want to create a "new" application. You probably just
want to get a pointer to the existing application. I'm not sure how to do
this in csharp, but here is some C++ code from an Outlook add-in to
accomplish this:
HRESULT BSAddIn::GetOutlookApp(IExchExtCallback *pmecb,
Outlook::_ApplicationPtr &rOLAppPtr)
{
try
{
IOutlookExtCallback *pOutlook = NULL;
HRESULT hRes = pmecb->QueryInterface(IID_IOutlookExtCallback,(void **)
&pOutlook);
if (pOutlook)
{
IUnknown *pUnk = NULL;
pOutlook->GetObject(&pUnk);
LPDISPATCH lpMyDispatch;
if (pUnk != NULL)
{
hRes = pUnk->QueryInterface(IID_IDispatch, (void **)
&lpMyDispatch);
pUnk->Release();
}
if (lpMyDispatch)
{
OLECHAR * szApplication = L"Application";
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
DISPID dspid;
VARIANT vtResult;
lpMyDispatch->GetIDsOfNames(IID_NULL, &szApplication, 1,
LOCALE_SYSTEM_DEFAULT, &dspid);
lpMyDispatch->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD, &dispparamsNoArgs, &vtResult, NULL, NULL);
lpMyDispatch->Release();
rOLAppPtr= vtResult.pdispVal;
return S_OK;
}
}
}
catch(...)
{
}
return S_FALSE;
}
Mark
http://www.email-announcer.com
>I am following
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ht
ml/ol03csharp.asp
[quoted text clipped - 12 lines]
> Best regards
> Marcus
Marcus Eklund - 16 Dec 2004 16:35 GMT
Hi Mark,
Thanks for the answer.
I just solved it, a bit father down in that webpage i was reading, they
said what to use instead of Application. You had to use ApplicationClass
and it worked fine.
/Marcus
> Hi Marcus,
>
[quoted text clipped - 47 lines]
> Mark
> http://www.email-announcer.com