Auswählen einer Adresse

Im folgenden Codebeispiel wird die Verwendung des TAPI-Objekts veranschaulicht, um verfügbare Telefonieressourcen für eine Adresse zu untersuchen, die eine bestimmte Gruppe von Medientypanforderungen verarbeiten kann. In diesem Beispiel sind Audio und Video die erforderlichen Medien.

Bevor Sie dieses Codebeispiel verwenden, müssen Sie die Vorgänge in Initialize TAPI ausführen.

Hinweis

In diesem Beispiel sind die Fehlerüberprüfungen und -releases nicht vorhanden, die für Produktionscode geeignet sind.

// Declare the interfaces used to select an address.
IEnumAddress * pIEnumAddress;
ITAddress * pAddress;
ITMediaSupport * pMediaSupport;

// Use the TAPI object to enumerate available addresses.
hr = gpTapi->EnumerateAddresses( &pIEnumAddress );
// If (hr != S_OK) process the error here. 

// Locate an address that can support the media type the application needs.
while ( S_OK == pIEnumAddress->Next(1, &pAddress, NULL) )
{
    // Determine the media support.
    hr = pAddress->QueryInterface(
         IID_ITMediaSupport,
         (void **)&pMediaSupport
         );
    // If (hr != S_OK) process the error here. 

    // In this example, the required media type is already known.
    // The application can also use the address object to
    // enumerate the media supported, then choose from there.
    hr = pMediaSupport->QueryMediaType(
         TAPIMEDIATYPE_AUDIO|TAPIMEDIATYPE_VIDEO,
         &bSupport
         );
    // If (hr != S_OK) process the error here. 

    if (bSupport)
    {
        break;
    }
}
// pAddress is now a usable address.

ITTAPI::EnumerateAddresses

ITMediaSupport

TAPIMEDIATYPE_ Konstanten