获取本机电话号码的问题
小弟想要得到本机的电话号码,经过多方查询后得知可以用SmsGetPhoneNumber函数.在论坛的另一贴你找到以下一段代码
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 ");
byte* pCurrent = pAddr;
phoneaddr.AddressType = (AddressType)Marshal.ReadInt32((IntPtr)pCurrent);
pCurrent += Marshal.SizeOf(phoneaddr.AddressType);
phoneaddr.Address = Marshal.PtrToStringUni((IntPtr)pCurrent);
}
return phoneaddr;
}
但是考下来执行后,编译器说找不到类型或命名空间名称“PhoneAddress”(是否缺少 using 指令或程序集引用?).请问PhoneAddress是自己定义还是要应用什么.
小弟用的是VS2005 C#
|