读取手机通讯记录
代码
- //头文件和库
- #include "phone.h"
- #pragma comment(lib,"phone.lib")
- HRESULT hr = S_OK;
- HANDLE ph;
- hr = PhoneOpenCallLog(&ph);//初始打开
- CHR(hr);
- DWORD count,pp;
- hr = PhoneSeekCallLog(ph, CALLLOGSEEK_END, 0, &count);
- CHR(hr);
- for(int i = 0 ; i < (int)count ; i++)
- {
- hr = PhoneSeekCallLog(ph,CALLLOGSEEK_BEGINNING,i,&pp);
- CALLLOGENTRY pentry;
- pentry.cbSize = sizeof(CALLLOGENTRY);
- hr = PhoneGetCallLogEntry(ph,&pentry);
- CE_CallLog_Info_Get cLog;
- cLog.ftStartTime = pentry.ftStartTime;
- cLog.ftEndTime = pentry.ftEndTime;
- cLog.iom = pentry.iom;//0 IOM_MISSED,1 IOM_INCOMING,2 IOM_OUTGOING
- cLog.fOutgoing = pentry.fOutgoing;// direction of call. (Missed calls are incoming.)
- cLog.fConnected = pentry.fConnected;// Did the call connect? (as opposed to busy, no answer)
- cLog.fEnded = pentry.fEnded;// Was the call ended? (as opposed to dropped)
- cLog.fRoam = pentry.fRoam;// Roaming (vs. local)
- cLog.cidt = pentry.cidt;//0 CALLERIDTYPE_UNAVAILABLE,1 CALLERIDTYPE_BLOCKED,2 CALLERIDTYPE_AVAILABLE
- cLog.pszNumber = pentry.pszNumber;
- cLog.pszName = pentry.pszName;
- cLog.pszNameType = pentry.pszNameType;// "w" for work tel, "h" for home tel, for example
- cLog.pszNote = pentry.pszNote;// filename of associated Notes file
- }
- Error:
- PhoneCloseCallLog (ph);