Forum Discussion

arthurqv's avatar
arthurqv
Occasional Contributor
7 years ago

I am trying to add several source files to a profiling area in C++ in Visual Studio2015.

I tried to mimic the VB script example, but my program always crashes when I try to add a second item to my created area. If I only add one item, it works fine. Does anybody have a C++ VS2015 example...
  • arthurqv's avatar
    arthurqv
    7 years ago

    Actually, I solved my problem, but I'm not 100% sure why:

    The key was to reset the two CComPtr inside the loop. Not sure why, but I am not a COM expert:

    CComPtr <IaqCOMAccessAreaItem> areaValue

    CComPtr <IaqCOMAccessDbgSymbol> SrcFileSymbol;

    ......

    for (long j = 0; j < itemCount; j++)

     

    {

           areaValue = 0;

           SrcFileSymbol = 0;

           hr = modObject->get_Item(dtSourceFile, j, &SrcFileSymbol);

           SrcFileSymbol->get_FullName(&FullName);

           if (isFileNameOfInterest(FullName, listFileNames))

     

           {

                  hr = aqArea->AddItem(SrcFileSymbol, &areaValue);

     

           }

    }

    Thanks to all for the suggestions.