Read phoneBook of a SIM card on a Smartphone

Bonjour, j'essaie de lire le rpertoire d'un smatphone, voici mon 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), 32, phonebookEntry)
SimDeinitialize(hSim)

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

End Function
-

Normalement, je devrais retrouver toutes les informations dans phonebookEntry...
On est bien d'accord?
Et ba rien du tout !
Si quelqu'un peut m'indiquer mon/mes erreur(s) ce serait cool

Merci d'avance

[1427 byte] By [jjm] at [2008-1-19]
# 1

Read data on a SIM card (PhoneBook)

It migth be better for you in english... isn't it ? Stick out tongue


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 find informations about the first entry in phonebookEntry object, but there is nothing in.
Does someone could explain me my error.

Thanks a lot

jjm at 2007-8-21 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2

Hi JJM,
Could you please send me a repro case (the code that you run that doesn't work)?
Thanks, -s

SoniaPignorel at 2007-8-21 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3
I'm sorry sonia, but I'm French, I don't understand very well what you want because I don't speack english very well...

In fact I've solve my problem, I read the PhoneBook of the SmarthPhone whith POOM and "in the hand" demo, instead of the Sim's one...

But if you're interrested in reading the SIM card, the is a very good sample here :
http://www.microsoft.com/downloads/details.aspx?FamilyId=B1F5CCAA-ADA2-42D4-8B70-95DC7D8F678C&displaylang=en

jjm at 2007-8-21 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...