Obtener numero de telefono

29/03/2006 - 13:58 por Daniela Constanza | Informe spam
Hola.

Necesito obtener el número de teléfono de una Tarjeta SIM.

Mi app está en PocketPc 2003 SE

Gracias

Preguntas similare

Leer las respuestas

#6 Daniela Constanza
30/03/2006 - 17:35 | Informe spam
Gracias nuevamente. Te pongo el código.

SimInitialize devuelve 0. EL problema sigue siendo que SmsGetPhoneNumber
devuelve -2147467259 y se lanza la excepción.



<System.Runtime.InteropServices.DllImport("sms.dll")> _

Private Shared Function SmsGetPhoneNumber(ByVal psmsaAddress As IntPtr) As
IntPtr

End Function

****************

Public Shared Function GetPhoneNumber() As PhoneAddress

Dim hSim, res0 As IntPtr

hSim = IntPtr.Zero

res0 = SimInitialize(IntPtr.Zero, Nothing, IntPtr.Zero, hSim)

If (res0.ToInt32 <> 0) Then

Throw New Exception("Could not initialize SMS.")

End If

Dim phoneaddr As PhoneAddress = New PhoneAddress

Dim buffer(512) As Byte

Dim pAddr() As Byte = buffer

Dim ipAddr As IntPtr = Marshal.AllocHLocal(pAddr.Length)

Dim res As IntPtr = IntPtr.Zero

Try

res = SmsGetPhoneNumber(ipAddr)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

If (res.ToInt32 <> 0) Then

Throw New Exception("Could not get phone number from SIM")

End If

phoneaddr.AddressType =
System.Runtime.InteropServices.Marshal.ReadInt32(ipAddr)

ipAddr =
IntPtr.op_Explicit(System.Runtime.InteropServices.Marshal.SizeOf(phoneaddr.AddressType)
+ ipAddr.ToInt32)

phoneaddr.Address =
System.Runtime.InteropServices.Marshal.PtrToStringUni(ipAddr)

SimDeinitialize(hSim)

Return phoneaddr

End Function
Respuesta Responder a este mensaje
#7 José Miguel Torres
31/03/2006 - 08:19 | Informe spam
Perdon,
perdon,perdon,perdon,perdon,perdon,perdon,perdon,perdon,perdon,.^1000

Te he liado.. disculpas... no es SmsGetPhoneNumber, por eso no te
funciona es SimReadphonebookEntry

mira estos enlaces
http://dotnet247.com/247reference/m...07248.aspx
http://forums.microsoft.com/msdn/sh...spx?postid086&siteid=1

disculpa de nuevo, no se en que estaba pensando...

saludos


José Miguel Torres
jtorres_diaz~~ARROBA~~terra.es
http://jmtorres.blogspot.com
http://www.desarrolloMobile.NET


"Daniela Constanza" escribió en el mensaje
news:uNuhq%
Gracias nuevamente. Te pongo el código.

SimInitialize devuelve 0. EL problema sigue siendo que SmsGetPhoneNumber
devuelve -2147467259 y se lanza la excepción.



<System.Runtime.InteropServices.DllImport("sms.dll")> _

Private Shared Function SmsGetPhoneNumber(ByVal psmsaAddress As IntPtr) As
IntPtr

End Function

****************

Public Shared Function GetPhoneNumber() As PhoneAddress

Dim hSim, res0 As IntPtr

hSim = IntPtr.Zero

res0 = SimInitialize(IntPtr.Zero, Nothing, IntPtr.Zero, hSim)

If (res0.ToInt32 <> 0) Then

Throw New Exception("Could not initialize SMS.")

End If

Dim phoneaddr As PhoneAddress = New PhoneAddress

Dim buffer(512) As Byte

Dim pAddr() As Byte = buffer

Dim ipAddr As IntPtr = Marshal.AllocHLocal(pAddr.Length)

Dim res As IntPtr = IntPtr.Zero

Try

res = SmsGetPhoneNumber(ipAddr)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

If (res.ToInt32 <> 0) Then

Throw New Exception("Could not get phone number from SIM")

End If

phoneaddr.AddressType =
System.Runtime.InteropServices.Marshal.ReadInt32(ipAddr)

ipAddr =
IntPtr.op_Explicit(System.Runtime.InteropServices.Marshal.SizeOf(phoneaddr.AddressType)
+ ipAddr.ToInt32)

phoneaddr.Address =
System.Runtime.InteropServices.Marshal.PtrToStringUni(ipAddr)

SimDeinitialize(hSim)

Return phoneaddr

End Function




Respuesta Responder a este mensaje
#8 Daniela Constanza
31/03/2006 - 11:21 | Informe spam
No te preocupes. He probado esto y sigo sin conseguirlo. Hace dos días que
busco en la red y no he encontrado algo que funcione... ¿?
<DllImport("cellcore.dll")> _

Private Shared Function SimReadPhonebookEntry(ByVal hSim As IntPtr, ByVal
dwLocation As IntPtr, ByVal dwIndex As System.UInt32,
<System.Runtime.InteropServices.Out()> ByRef lpPhonebookEntry As
SimPhoneBookEntry) As IntPtr

End Function

Public Shared Function ReadPhonebookEntry() As Char()

Dim hSim, res As IntPtr

hSim = IntPtr.Zero

Dim temp As Long

Dim index As New System.UInt32

'index = System.UInt32.Parse(1)

res = SimInitialize(IntPtr.Zero, Nothing, IntPtr.Zero, hSim)

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(0), index,
phonebookEntry)

SimDeinitialize(hSim)

Dim chars() As Char =
System.Runtime.InteropServices.Marshal.PtrToStringUni(phonebookEntry.dwAddressType)

Return chars

End Function
Respuesta Responder a este mensaje
#9 José Miguel Torres
31/03/2006 - 12:43 | Informe spam
A ver te paso la función en C#

[DllImport("cellcore.dll")]
private static extern uint SimReadPhonebookEntry(
IntPtr hSim, uint dwLocation, uint dwIndex, byte[] lpPhonebookEntry
);
public PhonebookEntry this[int index]
{
get
{
PhonebookEntry result = new PhonebookEntry();
uint hresult = SimReadPhonebookEntry(sHandle, 0x00000008, (uint)index + 1,
result.ToByteArray());

if(hresult != 0)
{
//empty slot
if(hresult==0x88000345)
{
return null;
}
else
{
throw new ExternalException("Error retrieving phonebook entry");
}
}

return result;
}
}

Fíjate en el segundo parametro le paso 0x000008, le hago saber que quiero
mis num de telfs.
El tercer parámetro es el índice de un total de n entradas de telef.

Pasalo a VB y prueba a ver, dime algo

saludos


José Miguel Torres
jtorres_diaz~~ARROBA~~terra.es
http://jmtorres.blogspot.com
http://www.desarrolloMobile.NET

"Daniela Constanza" escribió en el mensaje
news:
No te preocupes. He probado esto y sigo sin conseguirlo. Hace dos días
que busco en la red y no he encontrado algo que funcione... ¿?
<DllImport("cellcore.dll")> _

Private Shared Function SimReadPhonebookEntry(ByVal hSim As IntPtr, ByVal
dwLocation As IntPtr, ByVal dwIndex As System.UInt32,
<System.Runtime.InteropServices.Out()> ByRef lpPhonebookEntry As
SimPhoneBookEntry) As IntPtr

End Function

Public Shared Function ReadPhonebookEntry() As Char()

Dim hSim, res As IntPtr

hSim = IntPtr.Zero

Dim temp As Long

Dim index As New System.UInt32

'index = System.UInt32.Parse(1)

res = SimInitialize(IntPtr.Zero, Nothing, IntPtr.Zero, hSim)

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(0), index,
phonebookEntry)

SimDeinitialize(hSim)

Dim chars() As Char =
System.Runtime.InteropServices.Marshal.PtrToStringUni(phonebookEntry.dwAddressType)

Return chars

End Function


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida