IEnumUnknown->Next method causes a crash in MFC 7.1 (VS .net 2003) 
Author Message
 IEnumUnknown->Next method causes a crash in MFC 7.1 (VS .net 2003)

Hi,
  I have a couple of ActiveX controls inserted in my MFC (MFC 7.1) dialog
along with 2 buttons. I

used "EnumObjects" method on the ole container to enumerate the Embedded ole
objects.

I could get to the IUnknown pointers of the ole objects that i inserted in
the dialog. But after

returning IUnknown pointers for the activex controls (i inserted), the
IEnumUnknown->Next method

still tries return some uninitialized object and eventually causes a crash.

I used the following piece of code to enumerate the objects in the ole
container.

hr = pOleObj->GetClientSite( &pClientSite );
 if ( SUCCEEDED(hr) && pClientSite )
 {
  hr = pClientSite->GetContainer( &pCont );
  if ( SUCCEEDED(hr) && pCont )
  {
   hr = pCont->QueryInterface( IID_IUnknown, (void**)&pUnkCont );
   if ( SUCCEEDED(hr) && pUnkCont )
   {

    hr = pCont->EnumObjects( OLECONTF_EMBEDDINGS, &pEnumUnk );
    if ( SUCCEEDED(hr) && pEnumUnk )
    {
     // Enumerate the contained objects
 // This code causes a crash as it tries to return some uninitialized
object.
 // since i have two controls, it returned proper IUnKnowns' twice and the
next

time(supposed to come out of the loop), it fails and causes a crash.
     while (GetScode(pEnumUnk->Next(1, &pUnk, 0)) == S_OK &&

pUnk != 0)
     {
      pUnk->Release();
      pUnk = NULL;
     }
     pEnumUnk->Release();
     pEnumUnk = NULL;
    }
   }
  }
 }

Any reply on this would be greatly appreciated.

Reg



Sun, 18 Dec 2005 18:19:19 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VS.NET 2003 - Please explain the 7.1 Runtime

2. Slower compilation with VC Net 2003 (7.1) when compared to VC Net 7.0

3. VS.NET to 2003 Upgrade causes DEBUG build to fail

4. FYI: Bug in MFC 7.1 when opening a document from the shell (VS.Net 2003 latest beta)

5. MFC in VS.NET 2003

6. VS.NET 2003 VC++ and .NET controls

7. Debugging with VS.NET 2003 and VS 6

8. Problem catching events from WMP 7.1 in ATL/C++ (VS.net)

9. VCProject Save Method and .NET 2003

10. BUG: Namespace alias conflict (?) in managed project causes VS.NET 2003 to "crash"

11. Copy VS.NET 2003 settings to another machine...

12. VS.Net 2003 compiler issues

 

 
Powered by phpBB® Forum Software