R
Ramazan
I want to add new entry to main menu like "Help".
this code is adding to new entry to main menu bar behind of help
entry. But adding twice. Adding extra one entry to 0(zero) point in
main menu.
Thats first problem for me.
Another problem is this;
while outlook closing it gives that error "Unhandled exception at
0x03b3bab2 in OUTLOOK.EXE: 0xC000001D: Illegal Instruction."
when i remove my code it is working correctly.
How can i correct this error ?
in MAPI:
install(LPEXCHEXTCALLBACK peecb, ULONG eecontext, ULONG ulFlags)
function i write this code for adding new item to main menu as new
menu:
using namespace Outlook;
using namespace Office;
Outlook::_ApplicationPtr mOutlookApp = getOutlookApp(peecb);
Outlook::_ExplorerPtr lpExp=mOutlookApp->ActiveExplorer();
CComPtr<Office::_CommandBars> spCmdBars;
HRESULT hr = lpExp->get_CommandBars(&spCmdBars);
if (FAILED(hr))
{
//return NULL;
}
Office::CommandBarPtr lAnaMenu = spCmdBars->GetActiveMenuBar();
CommandBarControlsPtr lAnaMenuKontrols = lAnaMenu->GetControls();
CommandBarControlPtr lEsyaMenuPtr=NULL;
lMenuCount = lAnaMenuKontrols->GetCount();
CComVariant vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtFalse (VARIANT_FALSE);
CComVariant popupType (msoControlPopup);
CComVariant buttonType (msoControlButton);
lEsyaMenuPtr = lAnaMenuKontrols->Add(popupType,
vtEmpty,vtEmpty,lMenuCount, VARIANT_TRUE);
if (lEsyaMenuPtr==NULL)
{
return false;
}
lEsyaMenuPtr->PutCaption("TestAddinInMainMenu");
////////////////////////
I get ApplicationPtr in this function
I get callback function in MAPI install(LPEXCHEXTCALLBACK peecb, ULONG
eecontext, ULONG ulFlags) function with case EECONTEXT_VIEWER
//Getting _ApplicationPtr from callback
Outlook::_ApplicationPtr getOutlookApp(LPEXCHEXTCALLBACK iPeecb)
{
Outlook::_ApplicationPtr lRetAppPtr;
try
{
IOutlookExtCallback *pOutlook = NULL;
HRESULT hRes = iPeecb->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();
lRetAppPtr= vtResult.pdispVal;
return lRetAppPtr;
}
}
}
catch(...)
{
}
return lRetAppPtr;
}
////////////////////////
this code is adding to new entry to main menu bar behind of help
entry. But adding twice. Adding extra one entry to 0(zero) point in
main menu.
Thats first problem for me.
Another problem is this;
while outlook closing it gives that error "Unhandled exception at
0x03b3bab2 in OUTLOOK.EXE: 0xC000001D: Illegal Instruction."
when i remove my code it is working correctly.
How can i correct this error ?
in MAPI:
install(LPEXCHEXTCALLBACK peecb, ULONG eecontext, ULONG ulFlags)
function i write this code for adding new item to main menu as new
menu:
using namespace Outlook;
using namespace Office;
Outlook::_ApplicationPtr mOutlookApp = getOutlookApp(peecb);
Outlook::_ExplorerPtr lpExp=mOutlookApp->ActiveExplorer();
CComPtr<Office::_CommandBars> spCmdBars;
HRESULT hr = lpExp->get_CommandBars(&spCmdBars);
if (FAILED(hr))
{
//return NULL;
}
Office::CommandBarPtr lAnaMenu = spCmdBars->GetActiveMenuBar();
CommandBarControlsPtr lAnaMenuKontrols = lAnaMenu->GetControls();
CommandBarControlPtr lEsyaMenuPtr=NULL;
lMenuCount = lAnaMenuKontrols->GetCount();
CComVariant vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtFalse (VARIANT_FALSE);
CComVariant popupType (msoControlPopup);
CComVariant buttonType (msoControlButton);
lEsyaMenuPtr = lAnaMenuKontrols->Add(popupType,
vtEmpty,vtEmpty,lMenuCount, VARIANT_TRUE);
if (lEsyaMenuPtr==NULL)
{
return false;
}
lEsyaMenuPtr->PutCaption("TestAddinInMainMenu");
////////////////////////
I get ApplicationPtr in this function
I get callback function in MAPI install(LPEXCHEXTCALLBACK peecb, ULONG
eecontext, ULONG ulFlags) function with case EECONTEXT_VIEWER
//Getting _ApplicationPtr from callback
Outlook::_ApplicationPtr getOutlookApp(LPEXCHEXTCALLBACK iPeecb)
{
Outlook::_ApplicationPtr lRetAppPtr;
try
{
IOutlookExtCallback *pOutlook = NULL;
HRESULT hRes = iPeecb->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();
lRetAppPtr= vtResult.pdispVal;
return lRetAppPtr;
}
}
}
catch(...)
{
}
return lRetAppPtr;
}
////////////////////////