Errors while adding new item to main menu

Status
Not open for further replies.
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;

}

////////////////////////
 
On Mar 30, 10:17 am, Ramazan <ramazangir...@gmail.com> wrote:
> 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;

> }

> ////////////////////////


I must also give that information. This code is working correcly in

outlook 2003 but gives errors which i mentioned above in outlook 2000.

Ramazan
 
Hi Ramazan,


> Office::CommandBarPtr lAnaMenu = spCmdBars->GetActiveMenuBar();


Check your smart pointers before you use them!

if(IAnaMenu == NULL)

--> some error handling

Newer Outlook versions have more classes/methods/properties, so you

have to check if Outlook supports what you try to use.

SvenC
 
On Mar 30, 12:19 pm, "SvenC" <Sv...@nospam.nospam> wrote:
> Hi Ramazan,
>
> > Office::CommandBarPtr lAnaMenu = spCmdBars->GetActiveMenuBar();


> Check your smart pointers before you use them!

> if(IAnaMenu == NULL)
>  --> some error handling

> Newer Outlook versions have more classes/methods/properties, so you
> have to check if Outlook supports what you try to use.

> > SvenC


The proplem is not related to checking pointer. In outlook 2000 at new

mail screen mail menu, i can add new entry to main menu and it is no

problem while closing outlook.

I have removed that code from Extended MAPI from install

(LPEXCHEXTCALLBACK peecb, ULONG eecontext, ULONG ulFlags) method and

insert to onRead() method for test.

in onRead() method it is worked correctly and no error.

It may be related to mapi install() function. May be install function

with EECONTEXT_VIEWER must be return and than menu must be

inserted .But i don't know really.

Do you know in which method i can put menu insertion code which i

write.

Thanks .

Ramazan
 
Hi Ramazan,


> > > Office::CommandBarPtr lAnaMenu = spCmdBars->GetActiveMenuBar();

>

>> Check your smart pointers before you use them!
>

>> if(IAnaMenu == NULL)
> > --> some error handling
>

>> Newer Outlook versions have more classes/methods/properties, so you
> > have to check if Outlook supports what you try to use.


> The proplem is not related to checking pointer. In outlook 2000 at new
> mail screen mail menu, i can add new entry to main menu and it is no
> problem while closing outlook.


Can you build a debug dll of your addin and start a debug session with

Outlook.exe as the debuggee? Then you can see where the crash occurs.

Do you store any COM objects, so that they live longer than the

callback methods called in your client extension?

If yes, try not to store those pointers and see if that helps.

SvenC
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Outlook 2021 ScanPST errors (yet again ... sorry): repair button missing Outlook 2021 Using Outlook 5
J SCANPST errors Outlook PST repair? Using Outlook 1
pcunite Outlook 2019/O365 Build 13127.20408 errors when using MAPI calls Using Outlook 1
B Server errors Outlook 2007 Using Outlook 1
P errors appear every time I run SCANPST Using Outlook 3
A ScanPST finding errors but no Repair button Using Outlook 2
Y IMAP errors with Outlook 2016 Using Outlook 2
M Charter ISP Claims Outlook Generating STMP Errors of Too Many Recipients Using Outlook 1
Diane Poremsky BCM Errors after Upgrading to Windows 10 Using Outlook 1
Diane Poremsky Common Outlook Outgoing Server (SMTP) Errors Using Outlook 0
M attachments & time-out errors Using Outlook 4
L Issues with Outlook - errors detected in file Using Outlook 1
P 2013 AOL IMAP Sync Errors Using Outlook 5
E Multiple, intermittent Outlook 2010 errors Using Outlook 12
icacream errors have been detected... outlook.pst Using Outlook 10
J No errors from BCM 2007 but can't see database BCM (Business Contact Manager) 0
M The set of folders cannot be opened. Errors have been detected in the file. Using Outlook 11
A PDF Attachement Errors with Outlook 2010 Using Outlook 7
D VBA Macro Works in 2007 but errors in 2010 Using Outlook 2
J OL2003 Public Folder Sync Errors w/ Exchange 2010 Exchange Server Administration 11
V What is wrong with Outlook Connector - it still errors out on an EMPTY Hotmail Using Outlook.com accounts in Outlook 3
M Outllook 2000 - 2 Errors - The Information Service / The Messaging Interface Using Outlook 7
P IMAP errors with AOL during sync Outlook VBA and Custom Forms 3
B Import to Access errors out Outlook VBA and Custom Forms 20
T field mapping errors during import BCM (Business Contact Manager) 1
D BCM 2007 errors BCM (Business Contact Manager) 5
L Out of memory errors and Auto-linking hangs BCM (Business Contact Manager) 2
C HANDLING ERRORS USING FIND Outlook VBA and Custom Forms 3
J E-mail held in Outbox while Minimized Using Outlook 3
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
G How to have domain client use owa server instead of exchange server while connect to network Using Outlook 1
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
N How to add Dear & mail receipts name while reply to that mail in outlook2007 Outlook VBA and Custom Forms 1
D Conflict warning while editing Exchange Server Administration 0
J Outlook 2010 seems to hang when left inactive for a while Using Outlook 1
C Change From address while sending a new mail Outlook VBA and Custom Forms 5
G "Delay Delivery" Email fails to send if opened while in Outbox Using Outlook 4
P Threat to being a spammer while sending automatic Emails through VBA Using Outlook 3
S Renaming while drag and dropping to file Using Outlook 1
rohit I want to Populate Popup box while sending any email with attachment. Outlook VBA and Custom Forms 4
rohit I want to Populate Popup box while sending any email with attachment Using Outlook 1
S PoP up reminder while opening the outlook? Outlook VBA and Custom Forms 1
S Pop up reminder while i close outlook Outlook VBA and Custom Forms 5
J Outlook 2007 Error sharing Calendar: Error while preparing to send sharing message Using Outlook.com accounts in Outlook 2
Commodore Unified inbox shows moved messages for a while Using Outlook 4
M Disk Reads of outlook.pst while outlook not open Exchange Server Administration 1
V Need to add some text in subject while creating new mails - NEED VB CODINGS Using Outlook 4
D Remove extension while saving attachments Using Outlook 1
J OL2010 Create a new task while off line Exchange Server Administration 3
J Form 'While You Were Out' body text not working Using Outlook 24

Similar threads

Back
Top