IDebugPendingBreakpoint2::CanBind

보류 중인 이 중단점이 코드 위치에 바인딩할 수 있는지 여부를 결정합니다.

구문

int CanBind ( 
   out IEnumDebugErrorBreakpoints2 ppErrorEnum
);

매개 변수

ppErrorEnum
[out] 오류가 있을 수 있는 경우 IDebugErrorBreakpoint2 개체 목록을 포함하는 IEnumDebugErrorBreakpoints2 개체를 반환합니다.

Return Value

성공하면 S_OK.를 반환합니다. 중단점이 바인딩할 수 없는 경우 S_FALSE를 반환하며, 이 경우 ppErrorEnum 매개 변수에 의해 오류가 반환됩니다. 그렇지 않으면 오류 코드를 반환합니다. 중단점이 삭제된 경우 E_BP_DELETED를 반환합니다.

설명

이 메서드는 보류 중인 중단점이 바인딩된 경우 어떤 일이 발생할지 확인하기 위해 호출됩니다. Bind 메서드를 호출하여 보류 중인 중단점을 실제로 바인딩합니다.

예시

다음 예제에서는 CPendingBreakpointIDebugPendingBreakpoint2 인터페이스를 노출하는 간단한 개체에 대해 이 메서드를 구현하는 방법을 보여 줍니다.

HRESULT CPendingBreakpoint::CanBind(IEnumDebugErrorBreakpoints2** ppErrorEnum)
{
   HRESULT hr;
   HRESULT hrT;

   // Check for a valid pointer to an error breakpoint enumerator
   // interface; otherwise, return hr = E_INVALIDARG.
   if (ppErrorEnum)
   {
      // Verify that the pending breakpoint has not been deleted. If
      // deleted, then return hr = E_BP_DELETED.
      if (m_state.state != PBPS_DELETED)
      {
         // Verify that the breakpoint is a file/line breakpoint.
         if (IsFlagSet(m_pBPRequest->m_bpRequestInfo.dwFields, BPREQI_BPLOCATION) &&
             m_pBPRequest->m_bpRequestInfo.bpLocation.bpLocationType == BPLT_CODE_FILE_LINE)
         {
            hr = S_OK;
         }
         // If the breakpoint type is not a file/line breakpoint, then the
         // result should be an error breakpoint.
         else
         {
            // If the error breakpoint member variable does not have
            // allocated memory.
            if (!m_pErrorBP)
            {
               // Create, AddRef, and initialize a CErrorBreakpoint object.
               if (CComObject<CErrorBreakpoint>::CreateInstance(&m_pErrorBP) == S_OK)
               {
                  m_pErrorBP->AddRef();
                  m_pErrorBP->Initialize(this);
               }
            }

            // Create a new enumerator of error breakpoints.
             CComObject<CEnumDebugErrorBreakpoints>* pErrorEnum;
            if (CComObject<CEnumDebugErrorBreakpoints>::CreateInstance(&pErrorEnum) == S_OK)
            {
               // Get the IDebugErrorBreakpoint2 information for the
               // CErrorBreakpoint object.
               CComPtr<IDebugErrorBreakpoint2> spErrorBP;
               hrT = m_pErrorBP->QueryInterface(&spErrorBP);
               assert(hrT == S_OK);
               if (hrT == S_OK)
               {
                  // Initialize the new enumerator of error breakpoints
                  // with the IDebugErrorBreakpoint2 information.
                  IDebugErrorBreakpoint2* rgpErrorBP[] = { spErrorBP.p };
                  hrT = pErrorEnum->Init(rgpErrorBP, &(rgpErrorBP[1]), NULL, AtlFlagCopy);
                  if (hrT == S_OK)
                  {
                     // Verify that the passed IEnumDebugErrorBreakpoints2
                     // interface can be successful queried by the
                     // created CEnumDebugErrorBreakpoints object.
                     hrT = pErrorEnum->QueryInterface(ppErrorEnum);
                     assert(hrT == S_OK);
                  }
               }

               // Otherwise, delete the CEnumDebugErrorBreakpoints object.
               if (FAILED(hrT))
               {
                  delete pErrorEnum;
               }
            }

            hr = S_FALSE;
         }
      }
      else
      {
         hr = E_BP_DELETED;
      }
   }
   else
   {
      hr = E_INVALIDARG;
   }

   return hr;
}

참고 항목