Benjamin

静以修身,俭以养德,非澹薄无以明志,非宁静无以致远。
随笔 - 397, 文章 - 0, 评论 - 196, 引用 - 0
数据加载中……

WINCE通过clog.db表来读取和删除通话记录

  1 void ReadLog()
  2 {
  3     CEGUID ceguid;
  4     ////////////////////////int MAX_PATH = 1280;
  5     TCHAR szVolName[128];
  6     CREATE_INVALIDGUID(&ceguid);
  7     while(::CeEnumDBVolumes(&ceguid,szVolName,MAX_PATH))
  8     {
  9         if(wcsnicmp(L"SystemHeap",szVolName,10)==0)
 10         {
 11             /////将当前数据库卷定位到SystemHeap上
 12             break;
 13         }
 14     }
 15     
 16     CEOID ceoid;
 17     ceoid = 0;
 18     
 19     CENOTIFYREQUEST *pRequest = (CENOTIFYREQUEST *) LocalAlloc(LPTR,sizeof(CENOTIFYREQUEST));
 20     pRequest->dwSize = sizeof(CENOTIFYREQUEST);
 21     pRequest->hwnd = NULL;
 22     pRequest->hHeap = NULL; 
 23     pRequest->dwFlags = CEDB_EXNOTIFICATION;
 24     
 25     ////////////////////////////打开联系人数据库,并注册事件
 26     HANDLE hdDB;
 27     hdDB = ::CeOpenDatabaseEx(&ceguid,&ceoid,L"clog.db",0,0,pRequest);
 28     
 29     if(hdDB == INVALID_HANDLE_VALUE)
 30     {
 31 
 32         return;
 33     }
 34 
 35     int iCount;
 36     CEOIDINFO    oldinfo;
 37     CEOID CEoid =0;
 38     if(!CeOidGetInfoEx(&ceguid,ceoid,&oldinfo))
 39     {;}
 40 
 41 
 42     iCount = oldinfo.infDatabase.wNumRecords;
 43     DWORD dwIndex;
 44     if(!iCount)
 45         return;
 46     
 47     PBYTE pBuff;
 48     WORD wProps;
 49     DWORD dwRecSize;
 50     PCEPROPVAL pRecord;
 51     if(iCount >0)
 52     {
 53         for(int i = 0; i < iCount; ++ i)
 54         {
 55             ////////////////////////移动记录指针
 56             CEoid = CeSeekDatabase(hdDB,CEDB_SEEK_BEGINNING,i,&dwIndex);
 57             //ASSERT(CEoid !=0);
 58             pBuff = 0;    
 59             ////////////////////////读取所有字段值
 60             CEoid = CeReadRecordProps(hdDB,CEDB_ALLOWREALLOC,&wProps,NULL,&(LPBYTE)pBuff,&dwRecSize);
 61             //ASSERT(CEoid !=0);
 62             
 63             pRecord = (PCEPROPVAL)pBuff;
 64             FILETIME StartTime;
 65             FILETIME EndTime;
 66             int CallType;
 67             LPWSTR NumType;
 68             LPWSTR AllTime;
 69             LPWSTR Number;
 70             for(int i = 0; i < wProps; ++i)
 71             {
 72                 switch(pRecord->propid)
 73                 {
 74                 case 0x0006001f : 
 75                     Number = pRecord->val.lpwstr;
 76                     break;
 77                 case 0x0007001f:
 78                     AllTime = pRecord->val.lpwstr;
 79                     break;
 80                 case 0x000a001f:
 81                     NumType = pRecord->val.lpwstr;
 82                     break;
 83                 case 0x00020040:
 84                     StartTime = pRecord->val.filetime;
 85                     break;
 86                 case 0x00030040:
 87                     EndTime = pRecord->val.filetime;
 88                     break;
 89                 case 0x00040003:
 90                     CallType = pRecord->val.lVal;
 91                     break;
 92                 default:
 93                     break;
 94                 }
 95                 pRecord ++;
 96             }
 97                         LocalFree(pBuff);
 98         }
 99     }
100     /////////////////////////////////////////关闭数据库
101     if(! CloseHandle(hdDB))
102     {
103 
104         return;
105     }
106 }
 1 void DeleteLog(void)
 2 {
 3     CEGUID ceguid;
 4     TCHAR szVolName[128];
 5     CREATE_INVALIDGUID(&ceguid);
 6     while(::CeEnumDBVolumes(&ceguid,szVolName,MAX_PATH))
 7     {
 8         if(wcsnicmp(L"SystemHeap",szVolName,10)==0)
 9         {
10             /////将当前数据库卷定位到SystemHeap上
11             break;
12         }
13     }    
14     CEOID ceoid;
15     ceoid = 0;
16     
17     CENOTIFYREQUEST *pRequest = (CENOTIFYREQUEST *) LocalAlloc(LPTR,sizeof(CENOTIFYREQUEST));
18     pRequest->dwSize = sizeof(CENOTIFYREQUEST);
19     pRequest->hwnd = NULL;
20     pRequest->hHeap = NULL; 
21     pRequest->dwFlags = CEDB_EXNOTIFICATION;
22     
23     /////打开通话记录数据库,并注册事件
24     HANDLE hdDB;
25     hdDB = ::CeOpenDatabaseEx(&ceguid,&ceoid,L"clog.db",0,0,pRequest);
26     
27     if(hdDB == INVALID_HANDLE_VALUE)
28     {
29         return;
30     }
31     
32     int iCount;
33     CEOIDINFO    oldinfo;
34     CEOID CEoid =0;
35     //     PCEGUID pceguid = ceguid;
36     if(!CeOidGetInfoEx(&ceguid,ceoid,&oldinfo))
37     {;}
38 
39     //数据库的记录总数
40     iCount = oldinfo.infDatabase.wNumRecords;
41     if(0 == iCount)
42         return ;
43     
44     CEOID oid;
45     DWORD dwIndex;
46     oid = CeSeekDatabase(hdDB, CEDB_SEEK_BEGINNING, 0&dwIndex);
47     while(oid)
48     { 
49         // Update GUI with currently selected record
50         if(!CeDeleteRecord(hdDB, oid))
51         {;}
52 
53         oid = CeSeekDatabase(hdDB, CEDB_SEEK_CURRENT, 1&dwIndex);
54     }
55     
56     //关闭数据库
57     if(! CloseHandle(hdDB))
58     {
59         return ;
60     }
61 }

如果我们只是读取记录,并不编辑,那么通过phone.h来读取通话记录是比较方便的。附上主要代码
TCHAR LastIncomingCall[40];
TCHAR LastMissedCall[40];
TCHAR LastOutGoingCall[40];

TCHAR LastIncomingCallName[256];
TCHAR LastMissedCallName[256];
TCHAR LastOutGoingCallName[256];

HANDLE ph;
CALLLOGENTRY entry;
DWORD count;
entry.cbSize = sizeof(CALLLOGENTRY);
if(PhoneOpenCallLog(&ph)== S_OK)
{
   if(S_OK == PhoneSeekCallLog(ph, CALLLOGSEEK_BEGINNING, 0, &count))

//如果用CALLLOGSEEK_END那么count得到是的全部记录的个数

//如果用CALLLOGSEEK_BEGINNING那么count得是0
   {
    int lastIncallFlag = 0;
    int lastMissedCallFlag = 0;
    int lastOutgoingCallFlag = 0;

    while(PhoneGetCallLogEntry(ph, &entry) == S_OK)
    {
     if(( !lastIncallFlag)&&(entry.iom != IOM_OUTGOING) && (!entry.fOutgoing) )
     {
      //MessageBox(NULL, entry.pszNumber, TEXT("Last Incoming Call"), 0);
      lstrcpy(LastIncomingCall,   entry.pszNumber);
      if(!entry.pszName)
       lstrcpy(LastIncomingCallName,   TEXT("Unknow"));
      else
       lstrcpy(LastIncomingCallName,   entry.pszName);
      MessageBox(NULL,LastIncomingCall,LastIncomingCallName,0);
      lastIncallFlag = 1;
     }
     if(( !lastMissedCallFlag) && (entry.iom == IOM_MISSED))
     {
      lstrcpy(LastMissedCall,   entry.pszNumber);
      if(!entry.pszName)
       lstrcpy(LastMissedCallName,   TEXT("Unknow"));
      else
       lstrcpy(LastMissedCallName,   entry.pszName);
      MessageBox(NULL,LastMissedCall,LastMissedCallName,0);
      lastMissedCallFlag = 1;
     }
     if(( !lastOutgoingCallFlag) && (entry.iom == IOM_OUTGOING))
     {
      lstrcpy(LastOutGoingCall,   entry.pszNumber);
      if(!entry.pszName)
       lstrcpy(LastOutGoingCallName,   TEXT("Unknow"));
      else
       lstrcpy(LastOutGoingCallName,   entry.pszName);
      MessageBox(NULL,LastOutGoingCall,LastOutGoingCallName,0);
      lastOutgoingCallFlag = 1;
     }

     // Make phone
      /* PHONEMAKECALLINFO phonemakecall;
      phonemakecall.cbSize = sizeof(PHONEMAKECALLINFO);
      phonemakecall.dwFlags = PMCF_PROMPTBEFORECALLING;
      phonemakecall.pszDestAddress = entry.pszNumber;
      phonemakecall.pszAppName = NULL;
      phonemakecall.pszCalledParty = NULL;
      phonemakecall.pszComment = NULL;
      PhoneMakeCall(&phonemakecall);*/
    }

    //Show the call log filter
    //PhoneShowCallLog(CALLLOGFILTER_OUTGOING);
   }
}
PhoneCloseCallLog (ph);

打开phone.h发现在WM5.0上有两个两个函数在SDK里是没有的

第一个是

HRESULT PhoneAddSpeedDial(DWORD dwFlags, DWORD* piKey, const TCHAR* pszDisplayName, const TCHAR* pszTelNumber);

第二个是

HRESULT PhoneShowCallLog(CALLLOGFILTER iCallLogFilter);

typedef enum
{
     CALLLOGFILTER_ALL_CALLS,
     CALLLOGFILTER_MISSED,
     CALLLOGFILTER_INCOMING,
     CALLLOGFILTER_OUTGOING
} CALLLOGFILTER;

//++++++
//
//   PhoneAddSpeedDial
//
//        adds a speed dial entry
//
// dwFlags - currently unused, set to 0
//
// piKey - in/out: the key sequence which will invoke the speed dial.
//            currently an entry between 2 and 99 (inclusive) is valid.
//             the API will cause existing entries to be overwritten
//
// pszDisplayName - the non-empty display name for the speed dial
//
// pszTelNumber - the non-empty tel# to be dialed
//

HRESULT PhoneAddSpeedDial(DWORD dwFlags, DWORD* piKey, const TCHAR* pszDisplayName, const TCHAR* pszTelNumber);

 

 

posted on 2009-05-28 11:17 Benjamin 阅读(1882) 评论(1)  编辑 收藏 引用 所属分类: PDA/PPC开发

评论

# re: WINCE通过clog.db表来读取和删除通话记录[未登录]  回复  更多评论   

while(bRet=::CeEnumDBVolumes(&ceguid,szVolName,MAX_PATH))

szVolName 获得的值
第一次执行 \Documents and Setting\default.vol

第二次执行 \DBData\SYSCONFIG\notify.db

只获得这两次的值

没有你说的 SystemHeap 请问有遇到过吗,,谢谢
2015-03-09 15:21 | 陈杰

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理