none
查詢聯絡人疑問 RRS feed

  • 问题

  • Imports Microsoft.WindowsMobile.PocketOutlook

    Imports Microsoft.WindowsMobile.Status

    Imports Microsoft.WindowsMobile

    Public Class Form1

        Dim m_outlookSession As New OutlookSession

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            For Each c As Contact In m_outlookSession.Contacts.Items

                TextBox1.Text = c.MobileTelephoneNumber

            Next

        End Sub

    End Class

    上面程式碼我想知道我手機中聯絡人的號碼
    可是文書盒中什麼都沒有顯示

    請大家給點建議
    謝謝

    2009年3月11日 2:47

答案

全部回复

  • outlook联系人和sim卡联系人是不同的,楼主手机上的是不是sim卡联系人啊?
    施炯
    2009年3月11日 13:56
    版主
  •  
    對阿


    SIM卡或手機中的聯絡人要怎麼得知阿 ?
    謝謝

    2009年3月13日 1:55
  • 关于SIM卡联系人的获取,可以使用SIM Manager API函数来实现,
    具体你可以参考这个网页:SIM Programming On Windows Mobile,里面有源代码工程下载,希望对你有用。


    施炯
    2009年3月13日 2:34
    版主
  • 與裝置的遠端連接已經遺失
    請確認裝置連接狀態
    再重新偵錯

    下面程式碼執行後就會跳出上述視窗而終止
    請大家給點建議吧

    Imports System.Runtime.InteropServices 

    Public Class Form1

     

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim simCaps As New SimWrap.SimCaps

            Dim hSim As Integer = 0

            Dim phoneUsed As UInteger = 0

            Dim phoneTotal As UInteger = 0

            Dim smsUsed As UInteger = 0

            Dim smsTotal As UInteger = 0

            Dim result As Long

            result = SimWrap.SimInitialize(SimWrap.SIM_INIT_SIMCARD_NOTIFICATIONS, 0, 0, hSim)  

     

            Dim usedLocations As UInteger = 0        'Number of locations used

            Dim totalCapicity As UInteger = 0       'Total number of locations

            result = SimWrap.SimGetPhonebookStatus(hSim, SimWrap.SIM_PBSTORAGE_SIM, usedLocations, totalCapicity)

            SimWrap.SimDeinitialize(hSim)

            result = SimWrap.SimInitialize(SimWrap.SIM_INIT_SIMCARD_NOTIFICATIONS, 0, 0, hSim)

            Dim entry As New SimWrap.SIMPHONEBOOKENTRY

            Dim index As UInteger = 1       'Index of the entry to read

     

            For index = 1 To 1 'totalCapicity

                result = SimWrap.SimReadPhonebookEntry(hSim, SimWrap.SIM_PBSTORAGE_SIM, index, entry)

                Dim newContact As New SimWrap.CONTACTINFO

                newContact.contactName = Marshal.PtrToStringUni(entry.lpszText)

                newContact.contactNumber = Marshal.PtrToStringUni(entry.lpszAddress)

                TextBox1.Text = TextBox1.Text & newContact.contactName

                TextBox2.Text = TextBox2.Text & newContact.contactNumber

            Next

     

            'End SIM Manager session

            SimWrap.SimDeinitialize(hSim)

        End Sub

    End Class

     

     

    Imports System

    Imports System.Runtime.InteropServices

    Module Module1

        Public Class SimWrap

            Public Const SIM_CAPSTYPE_ALL As Integer = 63 '0x3F

            Public Const SIM_PBSTORAGE_SIM As Integer = 16 '0x10

            Public Const SIM_SMSSTORAGE_SIM As Integer = 2

            Public Const S_OK As Long = 0 '0x00000000

            Public Const SIM_INIT_SIMCARD_NOTIFICATIONS As Integer = 0

            <StructLayout(LayoutKind.Sequential)> _

            Public Structure SimLockingPwdLength

                Public dwFacility As UInteger

                Public dwPasswordLength As UInteger

            End Structure

     

            <StructLayout(LayoutKind.Sequential)> _

            Public Structure SimCaps

                Public cbSize As UInteger

                Public dwParams As UInteger

                Public dwPBStorages As UInteger

                Public dwMinPBIndex As UInteger

                Public dwMaxPBIndex As UInteger

                Public dwMaxPBEAddressLength As UInteger

                Public dwMaxPBETextLength As UInteger

                Public dwLockFacilities As UInteger

                Public dwReadMsgStorages As UInteger

                Public dwWriteMsgStorages As UInteger

                Public dwNumLockingPwdLengths As UInteger

                Public rgLockingPwdLengths0 As SimLockingPwdLength

                Public rgLockingPwdLengths1 As SimLockingPwdLength

                Public rgLockingPwdLengths2 As SimLockingPwdLength

                Public rgLockingPwdLengths3 As SimLockingPwdLength

                Public rgLockingPwdLengths4 As SimLockingPwdLength

                Public rgLockingPwdLengths5 As SimLockingPwdLength

                Public rgLockingPwdLengths6 As SimLockingPwdLength

                Public rgLockingPwdLengths7 As SimLockingPwdLength

                Public rgLockingPwdLengths8 As SimLockingPwdLength

                Public rgLockingPwdLengths9 As SimLockingPwdLength

            End Structure

     

            <StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _

            Public Structure SIMPHONEBOOKENTRY

                Public cbSize As UInteger

                Public dwParams As UInteger

                Public lpszAddress As IntPtr

                Public dwAddressType As UInteger

                Public dwNumPlan As UInteger

                Public lpszText As IntPtr

            End Structure

     

            Public Structure CONTACTINFO

                Public contactName As String

                Public contactNumber As String

            End Structure

     

            <DllImport("cellcore.dll")> _

            Public Shared Function SimInitialize(ByVal dwFlags As UInteger, ByVal lpfnCallBack As Integer, ByVal dwParam As UInteger, ByRef lphSim As Integer) As Integer

            End Function

            <DllImport("cellcore.dll")> _

            Public Shared Function SimDeinitialize(ByVal hSim As Integer) As Integer

            End Function

            <DllImport("cellcore.dll")> _

            Public Shared Function SimGetPhonebookStatus(ByVal hSim As Integer, ByVal dwLocation As UInteger, ByRef lpdwUsed As UInteger, ByRef lpdwTotal As UInteger) As Integer

            End Function

            <DllImport("cellcore.dll")> _

            Public Shared Function SimGetDevCaps(ByVal hSim As Integer, ByVal dwCapsType As UInteger, ByRef lpSimCaps As SimCaps) As Integer

            End Function

            <DllImport("cellcore.dll")> _

            Public Shared Function SimGetSmsStorageStatus(ByVal hSim As Integer, ByVal dwStorage As UInteger, ByRef lpdwUsed As UInteger, ByRef lpdwTotal As UInteger) As Integer

            End Function

            <DllImport("cellcore.dll")> _

            Public Shared Function SimReadPhonebookEntry(ByVal hSim As Integer, ByVal dwLocation As UInteger, ByVal index As UInteger, ByRef entry As SIMPHONEBOOKENTRY) As Integer

            End Function

        End Class

    End Module


    2009年3月16日 20:48
  •  simreadphonebookentry回傳直0
    應該就代表成功

    讀dwparams回來值為15
    代表field都正常

    可是

    lpszaddress代表電話號碼
    可是
    讀回來的值卻是 3670059
    why ??

    請大家給點建議
    謝謝
    2009年3月19日 3:29