locked
Where is the access violation? (C++/CEMAPI) RRS feed

  • Question

  • Hi

    I hope someone can help me spot this access violation, cause I don't see anything wrong with this code.

    [code]    HRESULT hr; 
        ICEMAPISession *pSession = NULL; 
        SRowSet * pRows = NULL; 
        IMsgStore * pStore = NULL; 
        IMAPITable *pTable; 
        LPENTRYID pEntryId = NULL; 
        ULONG cbEntryId = 0; 
        IMAPIFolder *pFolder; 
        ULONG ulObjType = 0; 
        IMAPITable *ptbl; 
        SRowSet *prowset = NULL; 
     
        hr = MAPIInitialize(NULL); 
        if (FAILED(hr))e
        {
            return;
        }

        hr = MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *) &pSession); 
        if (FAILED(hr))
        { 
           return;
        }  [/code]

    I'm quite sure the rest of the code is irrelevant as it's never reached.

    When MAPILogonEx is called an access violation occurs, I can post the disassembly if that's helpful, but I couldn't figure anything from it.

    The context of the code is as follows:

    This code as at the top of a member function of a class, function is defined as:

    [code]void CThreadClass::ProcessMessages()[/code]

    Function is called inside another function (of the same class). The idea is to launch this function inside a new thread, but I've removed the multithreading code for testing purposes, and now I'm simply calling the function from another function in the class.

    Can someone save me? I've compared this piece of code to an older piece of CEMAPI code I wrote and the MAPILogonEx call is identical, so I'm thinking it should be elsewhere that's causing it, but it crashes the moment it hits MAPILogonEx.

    Thanks

    Lionel
    "The moon could not continue shining if it had to pay attention to all the dogs barking at it."
    Tuesday, July 21, 2009 6:33 PM

Answers

  • Strange, I moved this out of the class into a global function and everything worked.
    "The moon could not continue shining if it had to pay attention to all the dogs barking at it."
    • Marked as answer by Y-Lionel Friday, July 24, 2009 12:46 AM
    Friday, July 24, 2009 12:45 AM