Sep 7 2010

Getting the Phone Call History

Category: MobileJoel Ivory Johnson @ 03:15

I've always resorted to using third party utilities for collecting the call history in my Windows Phone. But some one in the forums asked how to retrieve the call history. I finally took a look at this and it was much easier than I thought. The process is as simple as opening a handle to the call history, reading the call history, and then closing the handle. I put together the following code example for the user in the forums that had asked about it and thought to share it here. 

#include "stdafx.h"
#include "phone.h"



int _tmain(int argc, _TCHAR* argv[])
{
	HANDLE callLogHandle;
	CALLLOGENTRY logEntry;

	if(S_OK!=PhoneOpenCallLog(&callLogHandle))
		return -1;//failure
	
	logEntry.cbSize = sizeof(CALLLOGENTRY);

	while(S_OK==PhoneGetCallLogEntry(callLogHandle, &logEntry))
	{
		//The logEntry structure is populated with call data. 
		//do something with it here.
	}

	PhoneCloseCallLog (callLogHandle);

	return 0;
}

 

Tags:

Comments