다음을 통해 공유


컬렉션에서 개체 검색

다음 코드는 클라이언트 컬렉션에서 클라이언트의 IP 주소를 검색합니다. pClientsCollection 변수는 컬렉션에 대한 ISdoCollection 인터페이스를 가리킵니다. 컬렉션 개체를 검색하는 방법에 대한 자세한 내용은 컬렉션 검색을 참조하세요.

   HRESULT hr
   _variant_t vtClientName = L"Test Client";
   
   //
   // Get the client "Test Client" from the collection of clients
   //
   CComPtr<IDispatch> pFoundClientDispatch;
   hr = pClientsCollection->Item(&vtClientName, &pFoundClientDispatch);
   if (FAILED(hr))
   {
      return hr;
   }

   CComPtr<ISdo> pFoundClientSdo;
   hr = pFoundClientDispatch->QueryInterface(
      __uuidof(ISdo),
      (void **) &pFoundClientSdo
   );
   if (FAILED(hr))
   {
      return hr;
   }

   //
   // Get the IP address of that client 
   //
   _variant_t vtAddress;
   hr = pFoundClientSdo->GetProperty(PROPERTY_CLIENT_ADDRESS ,&vtAddress);
   if (FAILED(hr))
   {
      return hr;
   }

ISdoCollection::Item

컬렉션 검색

SysAllocString

SysFreeString

변형