如何取得通話紀錄(Mobile)
在上一篇有提到如何抓取SIM卡中連絡人的相關資料,這篇我們來測試一下抓取通話紀錄的部分。
首先,下面測試的程式碼是參考自Code Project的>Retrieving and Storing Call History,詳細的資料以及原始碼可以到code project去下載,下載之後解開壓縮,你會看到一個WindowsMobile6的資料夾,存取calllog相關的程式碼都在裡面,可以參考,不過程式碼都是C#的就是了。
在論壇上關於取得通話記錄的問題這篇也可以找到相關討論。
好,下面來看看實作的程式碼吧。
首先是模組的程式碼
叫用範例
首先,下面測試的程式碼是參考自Code Project的>Retrieving and Storing Call History,詳細的資料以及原始碼可以到code project去下載,下載之後解開壓縮,你會看到一個WindowsMobile6的資料夾,存取calllog相關的程式碼都在裡面,可以參考,不過程式碼都是C#的就是了。
在論壇上關於取得通話記錄的問題這篇也可以找到相關討論。
好,下面來看看實作的程式碼吧。
首先是模組的程式碼
Imports System.Runtime.InteropServices
Module Module2
_
Public Function PhoneOpenCallLog(ByRef ph As IntPtr) As IntPtr
End Function
_
Public Function PhoneGetCallLogEntry(ByVal h As IntPtr, ByRef pentry As CALLLOGENTRY) As IntPtr
End Function
_
Public Function PhoneCloseCallLog(ByVal h As IntPtr) As IntPtr
End Function
_
Public Function PhoneSeekCallLog(ByVal hdb As IntPtr, ByVal seek As CALLLOGSEEK, ByVal iRecord As UInteger, _
ByRef piRecord As UInteger) As IntPtr
End Function
_
Structure CALLLOGENTRY
_
Public cbSize As UInteger
_
Public ftStartTime As Long
_
Public ftEndTime As Long
_
Public iom As enumIOM
_
Public flags As fFlags
_
Public cidt As CALLERIDTYPE
_
Public pszNumber As IntPtr
_
Public pszName As IntPtr
_
Public pszNameType As IntPtr
_
Public pszNote As IntPtr
End Structure
Public Enum CALLERIDTYPE
UNAVAILABLE
BLOCKED
AVAILABLE
End Enum
Public Enum enumIOM
MISSED
INCOMING
OUTGOING
End Enum
_
Public Enum fFlags As Byte
Outgoing = &H1
Connected = &H2
Ended = &H4
Roam = &H8
End Enum
Public Enum CALLLOGSEEK
CALLLOGSEEK_BEGINNING = 2
CALLLOGSEEK_END = 4
End Enum
End Module
叫用範例
Public Sub enumCallLog()
Dim h As IntPtr
Dim entry As CALLLOGENTRY
Dim LastlogIndex As UInteger = 0
Dim CurrentlogIndex As UInteger = 0
entry = New CALLLOGENTRY()
entry.cbSize = Marshal.SizeOf(entry.GetType)
PhoneOpenCallLog(h)
If PhoneSeekCallLog(h, CALLLOGSEEK.CALLLOGSEEK_END, 0, LastlogIndex) = 0 Then
For i As Integer = 0 To LastlogIndex - 1
PhoneSeekCallLog(h, CALLLOGSEEK.CALLLOGSEEK_BEGINNING, i, CurrentlogIndex)
PhoneGetCallLogEntry(h, entry)
ListBox1.Items.Add(Marshal.PtrToStringUni(entry.pszName) & "," & _
Marshal.PtrToStringUni(entry.pszNumber))
Application.DoEvents()
Next
End If
End Sub
留言