Download the source code

To retrieve call history use the following API functions:

PhoneOpenCallLog
PhoneSeekCallLog
PhoneGetCallLogEntry
PhoneCloseCallLog

The following code fragment shows how to retrieve call history and add to a ListCtrl:

HANDLE hCallLog = NULL;
HRESULT hResult = PhoneOpenCallLog(&hCallLog);

if(E_FAIL == hResult)
{
return;
}

DWORD dwCount = 0;

hResult = PhoneSeekCallLog(hCallLog,CALLLOGSEEK_END,0,&dwCount);

PCALLLOGENTRY pLog = NULL;
SYSTEMTIME sTime = {0};
int nItem = 0;
int nImage = 0;
CString strLog;
CString strTime;

for(DWORD dwLog=0; dwLog<=dwCount; ++dwLog) { pLog = new CALLLOGENTRY; pLog->cbSize = sizeof(CALLLOGENTRY);

PhoneGetCallLogEntry(hCallLog,pLog);
FileTimeToSystemTime(&pLog->ftStartTime,&sTime);

strLog.Format(TEXT("%s"),pLog->pszName ? pLog->pszName : pLog->pszNumber);
strTime.Format(TEXT("%d-%d-%d %d:%02d"),sTime.wDay,sTime.wMonth,sTime.wYear,sTime.wHour,sTime.wMinute);

if(pLog->iom == IOM_MISSED)
nImage = 2;
else if(pLog->iom == IOM_INCOMING)
nImage = 1;
else
nImage = 0;

nItem = pList->InsertItem(dwLog,strLog,nImage);
pList->SetItemText(nItem,1,strTime);

if(pLog->pszName)
LocalFree(pLog->pszName);
if(pLog->pszNumber)
LocalFree(pLog->pszNumber);
if(pLog->pszNote)
LocalFree(pLog->pszNote);

delete pLog;
}

PhoneCloseCallLog(hCallLog);