G
Guest
Dear All,
I've read the article about Phone API at
http://msdn.microsoft.com/smartclie...ibrary/en-us/dnnetcomp/html/netcfphoneapi.asp
.. Then I've tried to run the sample program and only added one more line to
get the device phone number in the Form1_Load method:
private void Form1_Load(object sender, System.EventArgs e)
{
string phoneNum = Microsoft.Wireless.Sim.GetPhoneNumber().Address;
Microsoft.Wireless.Phone.MakeCall("5555551234");
}
However, the API cannot read the phone number and throws the exception.
unsafe public static PhoneAddress GetPhoneNumber()
{
PhoneAddress phoneaddr = new PhoneAddress();
Byte[] buffer = new Byte[516];
fixed (byte* pAddr = buffer)
{
IntPtr res = SmsGetPhoneNumber((IntPtr)pAddr);
if (res != IntPtr.Zero)
throw new Exception("Could not get phone number from SIM"); //
throws this exception
byte *pCurrent = pAddr;
phoneaddr.AddressType =
(AddressType)Marshal.ReadInt32((IntPtr)pCurrent);
pCurrent += Marshal.SizeOf(phoneaddr.AddressType);
phoneaddr.Address = Marshal.PtrToStringUni((IntPtr)pCurrent);
}
return phoneaddr;
}
I'm using O2 MINI. I can make phone calls without problems. May anyone let
me know what's wrong I got and how to solve it. Thanks in advance.
Albert
I've read the article about Phone API at
http://msdn.microsoft.com/smartclie...ibrary/en-us/dnnetcomp/html/netcfphoneapi.asp
.. Then I've tried to run the sample program and only added one more line to
get the device phone number in the Form1_Load method:
private void Form1_Load(object sender, System.EventArgs e)
{
string phoneNum = Microsoft.Wireless.Sim.GetPhoneNumber().Address;
Microsoft.Wireless.Phone.MakeCall("5555551234");
}
However, the API cannot read the phone number and throws the exception.
unsafe public static PhoneAddress GetPhoneNumber()
{
PhoneAddress phoneaddr = new PhoneAddress();
Byte[] buffer = new Byte[516];
fixed (byte* pAddr = buffer)
{
IntPtr res = SmsGetPhoneNumber((IntPtr)pAddr);
if (res != IntPtr.Zero)
throw new Exception("Could not get phone number from SIM"); //
throws this exception
byte *pCurrent = pAddr;
phoneaddr.AddressType =
(AddressType)Marshal.ReadInt32((IntPtr)pCurrent);
pCurrent += Marshal.SizeOf(phoneaddr.AddressType);
phoneaddr.Address = Marshal.PtrToStringUni((IntPtr)pCurrent);
}
return phoneaddr;
}
I'm using O2 MINI. I can make phone calls without problems. May anyone let
me know what's wrong I got and how to solve it. Thanks in advance.
Albert