Read data on a SIM card (PhoneBook)


Apr 28, 2005
Programming Experience

I'm trying to read the entries of the phoneRepertory of a smart phone (accessing datas of the SIM card)
here is my code :

<StructLayout(LayoutKind.Sequential)> _
Public Structure SimPhoneBookEntry
Public cbSize As IntPtr
Public dwParams As IntPtr
Public dwAddressType As IntPtr
Public dwNumPlan As IntPtr
Public lpszAddress As IntPtr
Public lpszText As IntPtr
End Structure 'SimPhoneBookEntry

Public Shared Function ReadPhonebookEntry() As Char()
Dim hSim, res As IntPtr
hSim = IntPtr.Zero
Dim temp As Long

'avant toute manipulation sur la carte SIM, il est indispensable de l'initialiser
res = SimInitialize(IntPtr.Zero, Nothing, IntPtr.Zero, hSim)
'on traite ici l'éventuelle erreur d'initialisation de la carte SIM
If (res.ToInt32 <> 0) Then
Throw New Exception("Could not initialize Sim.")
End If

Dim phonebookEntry As New SimPhoneBookEntry
res = SimReadPhonebookEntry(hSim, IntPtr.op_Explicit(SIM_NUMPBSTORAGES), 1, phonebookEntry)

Return System.Runtime.InteropServices.Marshal.PtrToStringUni(phonebookEntry.dwAddressType)

End Function
I should find informations about the first entry in phonebookEntry object, but there is nothing in.
Does someone could explain me my error.

Thanks a lot

Latest posts

Top Bottom