Freigeben über


Abrufen eines Objekts aus einer Auflistung

Der folgende Code ruft die IP-Adresse eines Clients aus einer Sammlung von Clients ab. Die Variable pClientsCollection verweist auf eine ISdoCollection-Schnittstelle für die Auflistung. Informationen zum Abrufen des Auflistungsobjekts finden Sie unter Abrufen einer Sammlung .

   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

Abrufen einer Sammlung

SysAllocString

SysFreeString

VARIANTE