插入新电话记录到呼叫记录中

来源:互联网 发布:tensorflow dropout层 编辑:程序博客网 时间:2024/04/30 05:05

- Pocket pc 2003 -

Code Snippetvoid DeleteCallLogEntry(TCHAR *szPhoneNumber)
{
 
 CEOID          PrayerSeekID;
 CEOIDINFO      CeObject;
 CEGUID         guidDBVol;

int            iLoop=0;
 int            NoOfRec;
 int            iFound=0;
 int            iLen;

long           lError;
 double         dwError;

TCHAR          szBuf[50];

SYSTEMTIME     Sys;

 

 CREATE_INVALIDGUID(&guidDBVol);

 hRdDB=NULL;

 RdCeOid=0;

 

 hRdDB  = CeOpenDatabaseEx2(&guidDBVol,&RdCeOid, "clog.db" ,NULL,CEDB_AUTOINCREMENT,NULL);
 if(hRdDB==INVALID_HANDLE_VALUE || hRdDB==NULL)
 {
     lError = GetLastError();


     switch(lError)
        {
            case ERROR_INVALID_PARAMETER:
                wsprintf(szBuf, TEXT("Invalid db information specified.%s/r/n"),RdDBName);
                break;
            case ERROR_FILE_NOT_FOUND:
                wsprintf(szBuf, TEXT("Database not found. %s/r/n"),RdDBName);
                break;
       }
 }

else
 {
 
    CeObject.wVersion = CEOIDINFOEX_VERSION ;

   if (!CeOidGetInfoEx(&guidDBVol,RdprayerCeOid, &CeObject) )

   {
     dwError=GetLastError();
     wsprintf(szBuf, TEXT("CeOidGetInfo failed with error (%ld)"), GetLastError());
     OutputDebugString(szBuf);
    }

    NoOfRec=CeObject.infDatabase.wNumRecords;

 

   PrayerSeekID=CeSeekDatabaseEx(hRdDB,CEDB_SEEK_BEGINNING,0,0,0);

  for(int LoopCount=0;LoopCount<=NoOfRec;LoopCount++)
   {
  
    if(!CeReadRecordPropsEx(hRdDB,CEDB_ALLOWREALLOC, &cRdPropID,NULL,&bRdData,&cbRdData,NULL)) 
    {
      if((dwError=GetLastError()) != ERROR_NO_MORE_ITEMS)
      {
       wsprintf(szBuf,TEXT("CeReadRecordProps failed to read database/r/n"));
      }
      break;

    }
    if( bRdData == NULL )
    {
      CurrentDialogHandle=GetForegroundWindow();
      MessageBox(CurrentDialogHandle,L"NO values in the DB",TEXT("clogdb"), MB_OKCANCEL );

     break;
    }
    else
    {
      RdVal = (PCEPROPVAL)bRdData + 4;

     if(wcscmp(RdVal->val.lpwstr,szPhoneNumber)==0)
      {
         CeDeleteRecord(hRdDB,PrayerSeekID);
         iFound=1;
         break;
      }
     else
     {
        PrayerSeekID=CeSeekDatabaseEx(hRdDB,CEDB_SEEK_CURRENT,0,0,0);
     }

   }
   }

   if(iFound==1)
   {
       RdTbl[0].propid   = 65538;  
       RdTbl[0].val.iVal  = iFirst;
   
       GetSystemTime(&Sys);

      SystemTimeToFileTime(&Sys,&SecondR);

      RdTbl[1].propid   = 131136; // start time of a call 
       RdTbl[1].val.filetime = SecondR;
   
       SystemTimeToFileTime(&Sys,&ThirdR);

      RdTbl[2].propid   = 196672;  // end time of a call 
       RdTbl[2].val.filetime = ThirdR;

      RdTbl[3].propid   =262147; // call mode
       RdTbl[3].val.iVal  =5; //拨出接是7  拨出不接是5  拨入接是6  拨入不接是4
  
       RdTbl[4].propid   = 393247;  // phone number
       RdTbl[4].val.lpwstr  =(LPTSTR)szPhoneNumber;

      RdTbl[5].propid   = 589827;
       RdTbl[5].val.lpwstr  =TEXT("");

      RdTbl[6].propid   = 3735595;
       RdTbl[6].val.lpwstr  =TEXT("");

 

     if(!CeWriteRecordProps(hRdDB, 0,6, RdTbl))
      {
        lError=GetLastError();
      }

  }
  

 }
 
 CloseHandle(hRdDB);
}


 

原创粉丝点击