Read data from SIM (phone repertory)

Hi,

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)
SimDeinitialize(hSim)

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

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

Thanks a lot

[1430 byte] By [jjm] at [2008-1-12]
# 1
There are two suggestions here. First is that by default your contacts are not stored on the SIM but in the phone memory and you should use POOM to access them. Secondly if you do have contacts on the SIM, perhaps your SIM card came out of another phone type, then try the OpenNETCF.Phone.Sim.Phonebook code, you can either use it from the compiled v1.3 release (www.opennetcf.org/sdf/) or take a look at the code in the vault:-
http://vault.netcf.tv/VaultService/VaultWeb/ShowFolder.aspx?repid=2&path=%24%2fSDF%2fOpenNETCF.Phone%2fSim
(username guest, password guest)

Peter

PeterFoot at 2007-8-21 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...