Getting Call Logs
Most of the people today choose powerful pda's or others that have extended programming ability as a phone.
As i am developing a finger friendly user interface (iphone like) to my pda (which has a windows mobile 2003 se OS), i did som research on google on google to find out, how to fetch data from many components of the phone programmatically.
First thing i will talk about Mobile Programming on PDA, how to fetch recent call history from WM2003 device (and possibly from WM5.0,6.0,6.1 devices).
To fetch call logs we will use "phone.h" header provided with Windows Mobile SDK.(By the way click plus sign to extend code)

std::vector<PCALLLOGENTRY> lst; HANDLE ph = NULL; HRESULT result; DWORD lastEntryIndex = 0; DWORD currentEntryIndex = 0; result = PhoneOpenCallLog(&ph); if(result == E_FAIL) return lst; result = PhoneSeekCallLog(ph, CALLLOGSEEK_END, 0, &lastEntryIndex); if (result == E_FAIL) { DWORD err = GetLastError(); PhoneCloseCallLog(ph); return lst; } result = PhoneSeekCallLog(ph, CALLLOGSEEK_BEGINNING, 0, ¤tEntryIndex); if (result == E_FAIL) { PhoneCloseCallLog(ph); return lst; }
At this code we get our call log handle with "PhoneOpenCallLog". Since windows mobile api is mostly written in c like style, we have to pass this handle to other phone functions. If function fails we simply return.
After getting handle we try to get last index with function "PhoneSeekCallLog". As you can see like the most of the other windows api functions, we send the HANDLE value. Again we have to check errors if something bad happens.
To get current(start) position of the index, again we use the same function with CALLLOGSEEK_BEGINNING parameter.
Since we got our starting and ending index now we can get our call history in a 'for' loop.

for(DWORD i = 0; i <= lastEntryIndex; i ) { PCALLLOGENTRY call = new CALLLOGENTRY(); call->cbSize = sizeof(CALLLOGENTRY); result = PhoneGetCallLogEntry(ph, call); if(result == E_FAIL) { PhoneCloseCallLog(ph); return lst; } lst.push_back(call); }
Since we seek to the first value with this handle before, now we can loop and get all the call logs. "PhoneGetCallLogEntry" don't get the parameter of index value. It increments the position at background somewhere inside winapi with handle. Since call log is a database on phone (which is clog.db), It simple wraps user from working with offsets of the database.
We are setting size parameter of the CALLLOGENTRY format because, in future versions of the Windows Mobile, size of the CALLLOGENTRY might change and this will give us the compability without changing code.

typedef struct { DWORD cbSize; // sizeof CALLLOGENTRY FILETIME ftStartTime; FILETIME ftEndTime; IOM iom; BOOL fOutgoing:1; // direction of call. (Missed calls are incoming.) BOOL fConnected:1; // Did the call connect? (as opposed to busy, no answer) BOOL fEnded:1; // Was the call ended? (as opposed to dropped) BOOL fRoam:1; // Roaming (vs. local) CALLERIDTYPE cidt; PTSTR pszNumber; PTSTR pszName; PTSTR pszNameType; // "w" for work tel, "h" for home tel, for example PTSTR pszNote; // filename of associated Notes file } CALLLOGENTRY, *PCALLLOGENTRY;
Here we see the contents of the struct, when we look at the msdn reference, it indicates that
| Quote From: Microsoft |
cbSize |
PTSTR is simply constant TCHAR pointer which is,
If UNICODE defined WCHAR(wide char), if not defined CHAR(ascii char) pointer. You can print it with

std::vector<PCALLLOGENTRY> lst = GetCallLogs(); PCALLLOGENTRY pcle = lst[0];
With these article now you can fetch recent call list.
Have fun