locked
How can i Delete a entry in call history in Window mobile 6 using .Net ? RRS feed

  • Question

  • Hi

     I am using the Windows Mobile 6 , .Net 2.0 and C# for Coding.. 

    My requirement is that i should delete a call entry(most recent call)  from the Call history .

    I dont know How can i get this done..

    Please give me some idea or how to do that ? or any code snippets or useful links

     

    Thanks a lot in Advance

     

    Sathish

     

     

     

    Monday, June 28, 2010 5:38 AM

Answers

  • Hi,

    The documented APIs for the CallLog are all read-only. You could 
    work around this by using the CE database APIs(CEDB or EDB API's)
    and delete records from the call log database manually, but this
    is not supported and may cause unknown problems.

    For Windows Mobile 5 and higher, use EDB and its in the volume
    \pim.vol in the clog.db database

    You may go through these link mentioned below

    http://www.codeproject.com/tips/68144/Modifying-the-Call-History-on-
    Windows-Mobile.aspx

    http://minhdanh2002.blogspot.com/2008/11/read-write-call-history.html
    Monday, June 28, 2010 6:55 AM
  • public partial class Form1 : Form
     {
     public Form1()
     {
      InitializeComponent();
     }
    
     private void btnDelete_Click(object sender, EventArgs e)
     {
      CEGUID ceGuid = new CEGUID();
      bool ok;
    
      ok = Calley.CeMountDBVolEx(ref ceGuid, "\\pim.vol", IntPtr.Zero, Calley.OPEN_EXISTING);
    
      int idCallLog = 0;
    
      unsafe
      {
      // open the calllog table
      IntPtr m_hDBCallLog = Calley.CeOpenDatabaseEx2(ref ceGuid, ref idCallLog, "clog.db", IntPtr.Zero, Calley.CEDB_AUTOINCREMENT, IntPtr.Zero);
    
      //3. seek to the beginning of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
      //4. attempt to read the records
      int wProps = 5; //length of property array
      int dwBuf = 0; //size of read buffer is returned here
    
      //IntPtr retVal;//pointer to returned buffer
      byte* retVal; //pointer to returned buffer
    
      //array containing the property to be retrieved
      int[] propsToRead = new int[5] { Calley.colStartTime, Calley.colEndTime, Calley.colCallNumber, Calley.colCallName, Calley.colCallFlags };
      //int recordToBeDeleted = 0;
    
      //perform actual reading of the record
      fixed (int* pArray = propsToRead)
      {
       int readRecordID = Calley.CeReadRecordPropsEx(m_hDBCallLog, Calley.CEDB_ALLOWREALLOC, ref wProps, new IntPtr((void*)pArray), &retVal, ref dwBuf, IntPtr.Zero);
       recordToBeDeleted = readRecordID; 
      }
    
    
      //5. retrieve the properties of the read record and print on screen  
      byte[] retValBytes = new byte[dwBuf];
      Marshal.Copy(new IntPtr(retVal), retValBytes, 0, dwBuf);
      //CEPROPVAL[] propVals = new CEPROPVAL[wProps];
      //Marshal.PtrToStructure(new IntPtr(retVal), propVals);
    
      Boolean isDeleted = Calley.CeDeleteRecord(m_hDBCallLog, recordToBeDeleted);
      }
      //6. unmount the database
      ok = Calley.CeUnmountDBVol(ref ceGuid);
     }
    
    
     }
    
    And the class calley i used is
    
     
    
    public class Calley
     {
    
     //1a. CONSTANTS FOR API FUNCTION CALLS
     public const int OPEN_EXISTING = 3;
     public const int CEDB_AUTOINCREMENT = 1;
     public const int CEDB_SEEK_BEGINNING = 2;
     public const int CEDB_ALLOWREALLOC = 1;
    
     //1b. CONSTANTS IDENTIFYING COLUMNS TO BE RETRIEVED FROM EDB clog.db DATABASE
     /*
     CEPROPID propReserved1 MAKELONG(CEVT_I2, 1); //Always 1
     CEPROPID propStartTime = MAKELONG(CEVT_FILETIME, 2); //call start time 
     CEPROPID propEndTime = MAKELONG(CEVT_FILETIME, 3); //call end time
     CEPROPID propCallFlags = MAKELONG(CEVT_I4, 4); //Identify call property (connected, roaming, incoming, outgoing, missed, etc.), every bit has a certain meaning
     CEPROPID propSomeText = MAKELONG(CEVT_LPWSTR, 5); //Some texts to display
     CEPROPID propCallNumber = MAKELONG(CEVT_LPWSTR, 6); //called/incoming number
     CEPROPID propCallName = MAKELONG(CEVT_LPWSTR, 7); //name from address book corresponding to the number
     CEPROPID propReserved2 = MAKELONG(CEVT_I4, 8); //always 0
     CEPROPID propID = MAKELONG(CEVT_AUTO_I4, 9); //Sequence number, auto-increase
     */
     public const int colStartTime = 131136;
     public const int colEndTime = 196672;
     public const int colCallNumber = 393247;
     public const int colCallName = 458783;
     public const int colCallFlags = 262147;
    
    
     //BOOL CeMountDBVolEx(INOUT PCEGUID pGuid, IN LPWSTR pwszDBVol, IN CEVOLUMEOPTIONS* pOptions, IN DWORD dwFlags);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeMountDBVolEx(ref CEGUID pGuid, string pwszDBVol, IntPtr pOptions, int dwFlags);
    
     //HANDLE CeOpenDatabaseEx2(PCEGUID pguid, PCEOID poid, LPWSTR lpszName, SORTORDERSPECEX* pSort, DWORD dwFlags, CENOTIFYREQUEST* pReq);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern IntPtr CeOpenDatabaseEx2(ref CEGUID pGuid, ref int poid, string lpszName, IntPtr pSort, int dwFlags, IntPtr pReq);
    
     //CEOID CeSeekDatabase(HANDLE hDatabase, DWORD dwSeekType, DWORD dwValue, LPDWORD lpdwIndex);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern int CeSeekDatabase(IntPtr hDatabase, int dwSeekType, int dwValue, IntPtr lpdwIndex);
    
     //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
     [DllImport("coredll.dll", SetLastError = true)]
     public static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
     //BOOL CeUnmountDBVol(PCEGUID pguid);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeUnmountDBVol(ref CEGUID pGuid);
    
     //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
     //[DllImport("coredll.dll", SetLastError = true)]
     //static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeDeleteRecord(IntPtr hDbase, int oidRecord);
    
    
    
     }
    
     public struct CEGUID
     {
     int Data1;
     int Data2;
     int Data3;
     int Data4;
     }
    
    
    The above code snippet works fine,,,,,,The above code Deletes the First record in the Call Log
    -----------------------------------------------------------------
    If u want to Delete the last record(the most recent one)
    
    Add the line to class Calley
    
    public const int CEDB_SEEK_END= 4;
    
    Then Replace
    
     //3. seek to the beginning of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
    
    With
    
     //3. seek to the End of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_END, 0, IntPtr.Zero); 
    
    
    Thats it this will delete the most recent Call...
    
    
    
    
    
    
    
    
    
    


    Thanks
    Sathish
    • Marked as answer by Sathishj1987 Saturday, July 10, 2010 1:22 PM
    Saturday, July 10, 2010 1:22 PM

  • Hi rahul jaiswal,

            Thank you very much for your reply...

     Is Deleting the call log Entry not supported in Windows Mobile 6 ?...

    And will Deleting a call entry from call history causes any problems in future..please let me know...

     

     

     

    Thanks

    Sathish

     


    public partial class Form1 : Form
     {
      public Form1()
      {
       InitializeComponent();
      }
    
      private void btnDelete_Click(object sender, EventArgs e)
      {
       CEGUID ceGuid = new CEGUID();
       bool ok;
    
       ok = Calley.CeMountDBVolEx(ref ceGuid, "\\pim.vol", IntPtr.Zero, Calley.OPEN_EXISTING);
    
       int idCallLog = 0;
    
       unsafe
       {
        // open the calllog table
        IntPtr m_hDBCallLog = Calley.CeOpenDatabaseEx2(ref ceGuid, ref idCallLog, "clog.db", IntPtr.Zero, Calley.CEDB_AUTOINCREMENT, IntPtr.Zero);
    
        //3. seek to the beginning of the database
        int ceOIDTemp = Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
        //4. attempt to read the records
        int wProps = 5; //length of property array
        int dwBuf = 0; //size of read buffer is returned here
    
        //IntPtr retVal;//pointer to returned buffer
        byte* retVal; //pointer to returned buffer
    
        //array containing the property to be retrieved
        int[] propsToRead = new int[5] { Calley.colStartTime, Calley.colEndTime, Calley.colCallNumber, Calley.colCallName, Calley.colCallFlags };
        int recordToBeDeleted = 0;
    
        //perform actual reading of the record
        fixed (int* pArray = propsToRead)
        {
         int readRecordID = Calley.CeReadRecordPropsEx(m_hDBCallLog, Calley.CEDB_ALLOWREALLOC, ref wProps, new IntPtr((void*)pArray), &retVal, ref dwBuf, IntPtr.Zero);
         recordToBeDeleted = readRecordID; 
        }
    
    
        //5. retrieve the properties of the read record and print on screen   
        byte[] retValBytes = new byte[dwBuf];
        Marshal.Copy(new IntPtr(retVal), retValBytes, 0, dwBuf);
        //CEPROPVAL[] propVals = new CEPROPVAL[wProps];
        //Marshal.PtrToStructure(new IntPtr(retVal), propVals);
    
        Boolean isDeleted = Calley.CeDeleteRecord(m_hDBCallLog, recordToBeDeleted);
       }
       //6. unmount the database
       ok = Calley.CeUnmountDBVol(ref ceGuid);
      }
    
    
     }
    
    And the class calley i used is
    
     
    
    public class Calley
     {
    
      //1a. CONSTANTS FOR API FUNCTION CALLS
      public const int OPEN_EXISTING = 3;
      public const int CEDB_AUTOINCREMENT = 1;
      public const int CEDB_SEEK_BEGINNING = 2;
      public const int CEDB_ALLOWREALLOC = 1;
    
      //1b. CONSTANTS IDENTIFYING COLUMNS TO BE RETRIEVED FROM EDB clog.db DATABASE
      /*
      CEPROPID propReserved1 MAKELONG(CEVT_I2, 1); //Always 1
      CEPROPID propStartTime = MAKELONG(CEVT_FILETIME, 2); //call start time 
      CEPROPID propEndTime = MAKELONG(CEVT_FILETIME, 3); //call end time
      CEPROPID propCallFlags = MAKELONG(CEVT_I4, 4); //Identify call property (connected, roaming, incoming, outgoing, missed, etc.), every bit has a certain meaning
      CEPROPID propSomeText = MAKELONG(CEVT_LPWSTR, 5); //Some texts to display
      CEPROPID propCallNumber = MAKELONG(CEVT_LPWSTR, 6); //called/incoming number
      CEPROPID propCallName = MAKELONG(CEVT_LPWSTR, 7); //name from address book corresponding to the number
      CEPROPID propReserved2 = MAKELONG(CEVT_I4, 8); //always 0
      CEPROPID propID = MAKELONG(CEVT_AUTO_I4, 9); //Sequence number, auto-increase
      */
      public const int colStartTime = 131136;
      public const int colEndTime = 196672;
      public const int colCallNumber = 393247;
      public const int colCallName = 458783;
      public const int colCallFlags = 262147;
    
    
      //BOOL CeMountDBVolEx(INOUT PCEGUID pGuid, IN LPWSTR pwszDBVol, IN CEVOLUMEOPTIONS* pOptions, IN DWORD dwFlags);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeMountDBVolEx(ref CEGUID pGuid, string pwszDBVol, IntPtr pOptions, int dwFlags);
    
      //HANDLE CeOpenDatabaseEx2(PCEGUID pguid, PCEOID poid, LPWSTR lpszName, SORTORDERSPECEX* pSort, DWORD dwFlags, CENOTIFYREQUEST* pReq);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern IntPtr CeOpenDatabaseEx2(ref CEGUID pGuid, ref int poid, string lpszName, IntPtr pSort, int dwFlags, IntPtr pReq);
    
      //CEOID CeSeekDatabase(HANDLE hDatabase, DWORD dwSeekType, DWORD dwValue, LPDWORD lpdwIndex);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern int CeSeekDatabase(IntPtr hDatabase, int dwSeekType, int dwValue, IntPtr lpdwIndex);
    
      //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
      [DllImport("coredll.dll", SetLastError = true)]
      public static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
      //BOOL CeUnmountDBVol(PCEGUID pguid);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeUnmountDBVol(ref CEGUID pGuid);
    
      //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
      //[DllImport("coredll.dll", SetLastError = true)]
      //static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeDeleteRecord(IntPtr hDbase, int oidRecord);
    
    
    
     }
    
     public struct CEGUID
     {
      int Data1;
      int Data2;
      int Data3;
      int Data4;
     }
    
    This will work fine
    • Marked as answer by Sathishj1987 Saturday, July 10, 2010 1:26 PM
    Saturday, July 10, 2010 1:25 PM

All replies

  • Hi,

    The documented APIs for the CallLog are all read-only. You could 
    work around this by using the CE database APIs(CEDB or EDB API's)
    and delete records from the call log database manually, but this
    is not supported and may cause unknown problems.

    For Windows Mobile 5 and higher, use EDB and its in the volume
    \pim.vol in the clog.db database

    You may go through these link mentioned below

    http://www.codeproject.com/tips/68144/Modifying-the-Call-History-on-
    Windows-Mobile.aspx

    http://minhdanh2002.blogspot.com/2008/11/read-write-call-history.html
    Monday, June 28, 2010 6:55 AM

  • Hi rahul jaiswal,

            Thank you very much for your reply...

     Is Deleting the call log Entry not supported in Windows Mobile 6 ?...

    And will Deleting a call entry from call history causes any problems in future..please let me know...

     

     

     

    Thanks

    Sathish

     

    Monday, June 28, 2010 8:20 AM
  • Ya its true that deleting call logs in WM is not supported because WM does not expose any API's for this. But if you wants to do this then you have to follow the steps mentioned in the above link.

    Otherwise no other alternative is there.

    Monday, June 28, 2010 8:45 AM
  • hi Rahul

     

    Can u please mail me the code to Sathishj2008@gmail.com if u have time ...

     

     

     

    Monday, June 28, 2010 12:12 PM
  • Hi ,

    i will paste my code here

    public partial class Form1 : Form
      {
        public Form1()
        {
          InitializeComponent();
        }
    
        private void btnDelete_Click(object sender, EventArgs e)
        {
          CEGUID ceGuid = new CEGUID();
          bool ok;
    
          ok = Calley.CeMountDBVolEx(ref ceGuid, "\\pim.vol", IntPtr.Zero, Calley.OPEN_EXISTING);
    
          int idCallLog = 0;
    
          unsafe
          {
            // open the calllog table
            IntPtr m_hDBCallLog = Calley.CeOpenDatabaseEx2(ref ceGuid, ref idCallLog, "clog.db", IntPtr.Zero, Calley.CEDB_AUTOINCREMENT, IntPtr.Zero);
    
            //3. seek to the beginning of the database
            int ceOIDTemp = Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
            //4. attempt to read the records
            int wProps = 5; //length of property array
            int dwBuf = 0; //size of read buffer is returned here
    
            //IntPtr retVal;//pointer to returned buffer
            byte* retVal; //pointer to returned buffer
    
            //array containing the property to be retrieved
            int[] propsToRead = new int[5] { Calley.colStartTime, Calley.colEndTime, Calley.colCallNumber, Calley.colCallName, Calley.colCallFlags };
            int recordToBeDeleted = 0;
    
            //perform actual reading of the record
            fixed (int* pArray = propsToRead)
            {
              int readRecordID = Calley.CeReadRecordPropsEx(m_hDBCallLog, Calley.CEDB_ALLOWREALLOC, ref wProps, new IntPtr((void*)pArray), &retVal, ref dwBuf, IntPtr.Zero);
              recordToBeDeleted = readRecordID; 
            }
    
    
            //5. retrieve the properties of the read record and print on screen      
            byte[] retValBytes = new byte[dwBuf];
            Marshal.Copy(new IntPtr(retVal), retValBytes, 0, dwBuf);
            //CEPROPVAL[] propVals = new CEPROPVAL[wProps];
            //Marshal.PtrToStructure(new IntPtr(retVal), propVals);
    
            Boolean isDeleted = Calley.CeDeleteRecord(m_hDBCallLog, recordToBeDeleted);
          }
          //6. unmount the database
          ok = Calley.CeUnmountDBVol(ref ceGuid);
        }
    
    
      }

    And the class calley i used is

     

    public class Calley
      {
    
        //1a. CONSTANTS FOR API FUNCTION CALLS
        public const int OPEN_EXISTING = 3;
        public const int CEDB_AUTOINCREMENT = 1;
        public const int CEDB_SEEK_BEGINNING = 2;
        public const int CEDB_ALLOWREALLOC = 1;
    
        //1b. CONSTANTS IDENTIFYING COLUMNS TO BE RETRIEVED FROM EDB clog.db DATABASE
        /*
        CEPROPID propReserved1 MAKELONG(CEVT_I2, 1); //Always 1
        CEPROPID propStartTime = MAKELONG(CEVT_FILETIME, 2); //call start time 
        CEPROPID propEndTime = MAKELONG(CEVT_FILETIME, 3); //call end time
        CEPROPID propCallFlags = MAKELONG(CEVT_I4, 4); //Identify call property (connected, roaming, incoming, outgoing, missed, etc.), every bit has a certain meaning
        CEPROPID propSomeText = MAKELONG(CEVT_LPWSTR, 5); //Some texts to display
        CEPROPID propCallNumber = MAKELONG(CEVT_LPWSTR, 6); //called/incoming number
        CEPROPID propCallName = MAKELONG(CEVT_LPWSTR, 7); //name from address book corresponding to the number
        CEPROPID propReserved2 = MAKELONG(CEVT_I4, 8); //always 0
        CEPROPID propID = MAKELONG(CEVT_AUTO_I4, 9); //Sequence number, auto-increase
        */
        public const int colStartTime = 131136;
        public const int colEndTime = 196672;
        public const int colCallNumber = 393247;
        public const int colCallName = 458783;
        public const int colCallFlags = 262147;
    
    
        //BOOL CeMountDBVolEx(INOUT PCEGUID pGuid, IN LPWSTR pwszDBVol, IN CEVOLUMEOPTIONS* pOptions, IN DWORD dwFlags);
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern bool CeMountDBVolEx(ref CEGUID pGuid, string pwszDBVol, IntPtr pOptions, int dwFlags);
    
        //HANDLE CeOpenDatabaseEx2(PCEGUID pguid, PCEOID poid, LPWSTR lpszName, SORTORDERSPECEX* pSort, DWORD dwFlags, CENOTIFYREQUEST* pReq);
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern IntPtr CeOpenDatabaseEx2(ref CEGUID pGuid, ref int poid, string lpszName, IntPtr pSort, int dwFlags, IntPtr pReq);
    
        //CEOID CeSeekDatabase(HANDLE hDatabase, DWORD dwSeekType, DWORD dwValue, LPDWORD lpdwIndex);
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern int CeSeekDatabase(IntPtr hDatabase, int dwSeekType, int dwValue, IntPtr lpdwIndex);
    
        //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
        [DllImport("coredll.dll", SetLastError = true)]
        public static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
        //BOOL CeUnmountDBVol(PCEGUID pguid);
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern bool CeUnmountDBVol(ref CEGUID pGuid);
    
        //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
        //[DllImport("coredll.dll", SetLastError = true)]
        //static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
        [DllImport("coredll.dll", SetLastError = true)]
        public static extern bool CeDeleteRecord(IntPtr hDbase, int oidRecord);
    
    
    
      }
    
      public struct CEGUID
      {
        int Data1;
        int Data2;
        int Data3;
        int Data4;
      }

    but still i cant get the record deleted

    and do i need to make use of the CEOID for CeDeleteRecord or i should use CEDB Api

    if i want to use the CEDB Api can any one provide me the dll or the wrapper class download link for that

     

    Thanks

    Sathish

     

     

     

    Tuesday, June 29, 2010 7:34 AM
  • public partial class Form1 : Form
     {
     public Form1()
     {
      InitializeComponent();
     }
    
     private void btnDelete_Click(object sender, EventArgs e)
     {
      CEGUID ceGuid = new CEGUID();
      bool ok;
    
      ok = Calley.CeMountDBVolEx(ref ceGuid, "\\pim.vol", IntPtr.Zero, Calley.OPEN_EXISTING);
    
      int idCallLog = 0;
    
      unsafe
      {
      // open the calllog table
      IntPtr m_hDBCallLog = Calley.CeOpenDatabaseEx2(ref ceGuid, ref idCallLog, "clog.db", IntPtr.Zero, Calley.CEDB_AUTOINCREMENT, IntPtr.Zero);
    
      //3. seek to the beginning of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
      //4. attempt to read the records
      int wProps = 5; //length of property array
      int dwBuf = 0; //size of read buffer is returned here
    
      //IntPtr retVal;//pointer to returned buffer
      byte* retVal; //pointer to returned buffer
    
      //array containing the property to be retrieved
      int[] propsToRead = new int[5] { Calley.colStartTime, Calley.colEndTime, Calley.colCallNumber, Calley.colCallName, Calley.colCallFlags };
      //int recordToBeDeleted = 0;
    
      //perform actual reading of the record
      fixed (int* pArray = propsToRead)
      {
       int readRecordID = Calley.CeReadRecordPropsEx(m_hDBCallLog, Calley.CEDB_ALLOWREALLOC, ref wProps, new IntPtr((void*)pArray), &retVal, ref dwBuf, IntPtr.Zero);
       recordToBeDeleted = readRecordID; 
      }
    
    
      //5. retrieve the properties of the read record and print on screen  
      byte[] retValBytes = new byte[dwBuf];
      Marshal.Copy(new IntPtr(retVal), retValBytes, 0, dwBuf);
      //CEPROPVAL[] propVals = new CEPROPVAL[wProps];
      //Marshal.PtrToStructure(new IntPtr(retVal), propVals);
    
      Boolean isDeleted = Calley.CeDeleteRecord(m_hDBCallLog, recordToBeDeleted);
      }
      //6. unmount the database
      ok = Calley.CeUnmountDBVol(ref ceGuid);
     }
    
    
     }
    
    And the class calley i used is
    
     
    
    public class Calley
     {
    
     //1a. CONSTANTS FOR API FUNCTION CALLS
     public const int OPEN_EXISTING = 3;
     public const int CEDB_AUTOINCREMENT = 1;
     public const int CEDB_SEEK_BEGINNING = 2;
     public const int CEDB_ALLOWREALLOC = 1;
    
     //1b. CONSTANTS IDENTIFYING COLUMNS TO BE RETRIEVED FROM EDB clog.db DATABASE
     /*
     CEPROPID propReserved1 MAKELONG(CEVT_I2, 1); //Always 1
     CEPROPID propStartTime = MAKELONG(CEVT_FILETIME, 2); //call start time 
     CEPROPID propEndTime = MAKELONG(CEVT_FILETIME, 3); //call end time
     CEPROPID propCallFlags = MAKELONG(CEVT_I4, 4); //Identify call property (connected, roaming, incoming, outgoing, missed, etc.), every bit has a certain meaning
     CEPROPID propSomeText = MAKELONG(CEVT_LPWSTR, 5); //Some texts to display
     CEPROPID propCallNumber = MAKELONG(CEVT_LPWSTR, 6); //called/incoming number
     CEPROPID propCallName = MAKELONG(CEVT_LPWSTR, 7); //name from address book corresponding to the number
     CEPROPID propReserved2 = MAKELONG(CEVT_I4, 8); //always 0
     CEPROPID propID = MAKELONG(CEVT_AUTO_I4, 9); //Sequence number, auto-increase
     */
     public const int colStartTime = 131136;
     public const int colEndTime = 196672;
     public const int colCallNumber = 393247;
     public const int colCallName = 458783;
     public const int colCallFlags = 262147;
    
    
     //BOOL CeMountDBVolEx(INOUT PCEGUID pGuid, IN LPWSTR pwszDBVol, IN CEVOLUMEOPTIONS* pOptions, IN DWORD dwFlags);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeMountDBVolEx(ref CEGUID pGuid, string pwszDBVol, IntPtr pOptions, int dwFlags);
    
     //HANDLE CeOpenDatabaseEx2(PCEGUID pguid, PCEOID poid, LPWSTR lpszName, SORTORDERSPECEX* pSort, DWORD dwFlags, CENOTIFYREQUEST* pReq);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern IntPtr CeOpenDatabaseEx2(ref CEGUID pGuid, ref int poid, string lpszName, IntPtr pSort, int dwFlags, IntPtr pReq);
    
     //CEOID CeSeekDatabase(HANDLE hDatabase, DWORD dwSeekType, DWORD dwValue, LPDWORD lpdwIndex);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern int CeSeekDatabase(IntPtr hDatabase, int dwSeekType, int dwValue, IntPtr lpdwIndex);
    
     //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
     [DllImport("coredll.dll", SetLastError = true)]
     public static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
     //BOOL CeUnmountDBVol(PCEGUID pguid);
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeUnmountDBVol(ref CEGUID pGuid);
    
     //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
     //[DllImport("coredll.dll", SetLastError = true)]
     //static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
     [DllImport("coredll.dll", SetLastError = true)]
     public static extern bool CeDeleteRecord(IntPtr hDbase, int oidRecord);
    
    
    
     }
    
     public struct CEGUID
     {
     int Data1;
     int Data2;
     int Data3;
     int Data4;
     }
    
    
    The above code snippet works fine,,,,,,The above code Deletes the First record in the Call Log
    -----------------------------------------------------------------
    If u want to Delete the last record(the most recent one)
    
    Add the line to class Calley
    
    public const int CEDB_SEEK_END= 4;
    
    Then Replace
    
     //3. seek to the beginning of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
    
    With
    
     //3. seek to the End of the database
      int recordToBeDeleted= Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_END, 0, IntPtr.Zero); 
    
    
    Thats it this will delete the most recent Call...
    
    
    
    
    
    
    
    
    
    


    Thanks
    Sathish
    • Marked as answer by Sathishj1987 Saturday, July 10, 2010 1:22 PM
    Saturday, July 10, 2010 1:22 PM

  • Hi rahul jaiswal,

            Thank you very much for your reply...

     Is Deleting the call log Entry not supported in Windows Mobile 6 ?...

    And will Deleting a call entry from call history causes any problems in future..please let me know...

     

     

     

    Thanks

    Sathish

     


    public partial class Form1 : Form
     {
      public Form1()
      {
       InitializeComponent();
      }
    
      private void btnDelete_Click(object sender, EventArgs e)
      {
       CEGUID ceGuid = new CEGUID();
       bool ok;
    
       ok = Calley.CeMountDBVolEx(ref ceGuid, "\\pim.vol", IntPtr.Zero, Calley.OPEN_EXISTING);
    
       int idCallLog = 0;
    
       unsafe
       {
        // open the calllog table
        IntPtr m_hDBCallLog = Calley.CeOpenDatabaseEx2(ref ceGuid, ref idCallLog, "clog.db", IntPtr.Zero, Calley.CEDB_AUTOINCREMENT, IntPtr.Zero);
    
        //3. seek to the beginning of the database
        int ceOIDTemp = Calley.CeSeekDatabase(m_hDBCallLog, Calley.CEDB_SEEK_BEGINNING, 0, IntPtr.Zero);
    
        //4. attempt to read the records
        int wProps = 5; //length of property array
        int dwBuf = 0; //size of read buffer is returned here
    
        //IntPtr retVal;//pointer to returned buffer
        byte* retVal; //pointer to returned buffer
    
        //array containing the property to be retrieved
        int[] propsToRead = new int[5] { Calley.colStartTime, Calley.colEndTime, Calley.colCallNumber, Calley.colCallName, Calley.colCallFlags };
        int recordToBeDeleted = 0;
    
        //perform actual reading of the record
        fixed (int* pArray = propsToRead)
        {
         int readRecordID = Calley.CeReadRecordPropsEx(m_hDBCallLog, Calley.CEDB_ALLOWREALLOC, ref wProps, new IntPtr((void*)pArray), &retVal, ref dwBuf, IntPtr.Zero);
         recordToBeDeleted = readRecordID; 
        }
    
    
        //5. retrieve the properties of the read record and print on screen   
        byte[] retValBytes = new byte[dwBuf];
        Marshal.Copy(new IntPtr(retVal), retValBytes, 0, dwBuf);
        //CEPROPVAL[] propVals = new CEPROPVAL[wProps];
        //Marshal.PtrToStructure(new IntPtr(retVal), propVals);
    
        Boolean isDeleted = Calley.CeDeleteRecord(m_hDBCallLog, recordToBeDeleted);
       }
       //6. unmount the database
       ok = Calley.CeUnmountDBVol(ref ceGuid);
      }
    
    
     }
    
    And the class calley i used is
    
     
    
    public class Calley
     {
    
      //1a. CONSTANTS FOR API FUNCTION CALLS
      public const int OPEN_EXISTING = 3;
      public const int CEDB_AUTOINCREMENT = 1;
      public const int CEDB_SEEK_BEGINNING = 2;
      public const int CEDB_ALLOWREALLOC = 1;
    
      //1b. CONSTANTS IDENTIFYING COLUMNS TO BE RETRIEVED FROM EDB clog.db DATABASE
      /*
      CEPROPID propReserved1 MAKELONG(CEVT_I2, 1); //Always 1
      CEPROPID propStartTime = MAKELONG(CEVT_FILETIME, 2); //call start time 
      CEPROPID propEndTime = MAKELONG(CEVT_FILETIME, 3); //call end time
      CEPROPID propCallFlags = MAKELONG(CEVT_I4, 4); //Identify call property (connected, roaming, incoming, outgoing, missed, etc.), every bit has a certain meaning
      CEPROPID propSomeText = MAKELONG(CEVT_LPWSTR, 5); //Some texts to display
      CEPROPID propCallNumber = MAKELONG(CEVT_LPWSTR, 6); //called/incoming number
      CEPROPID propCallName = MAKELONG(CEVT_LPWSTR, 7); //name from address book corresponding to the number
      CEPROPID propReserved2 = MAKELONG(CEVT_I4, 8); //always 0
      CEPROPID propID = MAKELONG(CEVT_AUTO_I4, 9); //Sequence number, auto-increase
      */
      public const int colStartTime = 131136;
      public const int colEndTime = 196672;
      public const int colCallNumber = 393247;
      public const int colCallName = 458783;
      public const int colCallFlags = 262147;
    
    
      //BOOL CeMountDBVolEx(INOUT PCEGUID pGuid, IN LPWSTR pwszDBVol, IN CEVOLUMEOPTIONS* pOptions, IN DWORD dwFlags);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeMountDBVolEx(ref CEGUID pGuid, string pwszDBVol, IntPtr pOptions, int dwFlags);
    
      //HANDLE CeOpenDatabaseEx2(PCEGUID pguid, PCEOID poid, LPWSTR lpszName, SORTORDERSPECEX* pSort, DWORD dwFlags, CENOTIFYREQUEST* pReq);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern IntPtr CeOpenDatabaseEx2(ref CEGUID pGuid, ref int poid, string lpszName, IntPtr pSort, int dwFlags, IntPtr pReq);
    
      //CEOID CeSeekDatabase(HANDLE hDatabase, DWORD dwSeekType, DWORD dwValue, LPDWORD lpdwIndex);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern int CeSeekDatabase(IntPtr hDatabase, int dwSeekType, int dwValue, IntPtr lpdwIndex);
    
      //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
      [DllImport("coredll.dll", SetLastError = true)]
      public static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
      //BOOL CeUnmountDBVol(PCEGUID pguid);
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeUnmountDBVol(ref CEGUID pGuid);
    
      //CEOID CeReadRecordPropsEx(HANDLE hDbase, DWORD dwFlags, LPWORD lpcPropID, CEPROPID* rgPropID, LPBYTE* lplpBuffer, LPDWORD lpcbBuffer, HANDLE hHeap);
      //[DllImport("coredll.dll", SetLastError = true)]
      //static unsafe extern int CeReadRecordPropsEx(IntPtr hDbase, int dwFlags, ref int lpcPropID, IntPtr rgPropID, byte** lplpBuffer, ref int lpcbBuffer, IntPtr hHeap);
    
      [DllImport("coredll.dll", SetLastError = true)]
      public static extern bool CeDeleteRecord(IntPtr hDbase, int oidRecord);
    
    
    
     }
    
     public struct CEGUID
     {
      int Data1;
      int Data2;
      int Data3;
      int Data4;
     }
    
    This will work fine
    • Marked as answer by Sathishj1987 Saturday, July 10, 2010 1:26 PM
    Saturday, July 10, 2010 1:25 PM