下列程式代碼範例示範如何使用TAPI對象來檢查可處理一組指定媒體類型需求的位址可用的電話語音資源。 在此範例中,音訊和視訊是必要的媒體。
使用此程式代碼範例之前,您必須在 初始化TAPI中執行作業。
注意
此範例沒有適用於生產程式代碼的錯誤檢查和版本。
// 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.