Hope this helps, its better than whats there already.
#include "stdafx.h"
#include <tapi3.h>
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
ITTAPI * gpTapi;
hr = CoInitialize(NULL);
//if ( CoInitializeEx(NULL,COINIT_MULTITHREADED) != S_OK )
//{
// printf("not initialised");
// return FALSE;
//}
hr = CoCreateInstance(
CLSID_TAPI,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITTAPI,
(LPVOID *)&;;gpTapi
);
hr = gpTapi->Initialize(); // Initialize TAPI.
if(hr == S_OK)
{
printf("CallerID:");
}
else
{
printf("No Devices");
}
// Pointer to our interface pointer
if ( SUCCEEDED ( hr ) )
{
// Call methods using pISL here.
printf("\n");
//do something useful
// enumerate available addresses.
//ITMediaSupport * pMediaSupport;
VARIANT_BOOL bSupport;
IEnumAddress * pIEnumAddress;
ITAddress * pAddress;
//event
hr = gpTapi->EnumerateAddresses( &;;pIEnumAddress );
while ( (S_OK == pIEnumAddress->Next(1, &;;pAddress, NULL) ) )
{
//hr = pAddress->QueryInterface(IID_ITMediaSupport,(void **)&;;pMediaSupport);
//hr = pMediaSupport->QueryMediaType((TAPIMEDIATYPE_DATAMODEM),&;;bSupport);
//if (bSupport)
//{
// break;
//}
ITAddressCapabilities * pAddressCaps;
long lType = 0;
BOOL bFoundAddress = FALSE;
hr = pAddress->QueryInterface(IID_ITAddressCapabilities, (void**)&;;pAddressCaps);
//hr = pAddressCaps->get_AddressCapability( AC_ADDRESSTYPES, &;;lType );
//hr = pAddressCaps->get_AddressCapability( AC_TRANSFERMODES, &;;lType );
hr = pAddressCaps->get_AddressCapability( AC_CALLERIDSUPPORT, &;;lType );
//AC_TRANSFERMODES
pAddressCaps->Release();
if ( SUCCEEDED(hr) )
{
printf("calleridOK ");
//printf(lType);
//printf("code: %d\n", lType);
}
//CAPABILITIES
// typedef enum ADDRESS_CAPABILITY {
// AC_ADDRESSTYPES,...
// AC_CALLERIDSUPPORT,
// ITAddressCapabilities cap;
// cap = pAddress as ITAddressCapabilities;
printf("\n");
}
//end useful code
}
else
{
//Error
printf("(error code %08x)\n", hr);
}
return 0;
}