请问园中的各位高手,在VS用C#开发mobile里,有没有办法读取手机那个IMIE唯一号。
Codepublic struct GeneralInfo { public string Manufacturer; public string Model; public string Revision; public string SerialNumber; public string SubscriberNumber; } /// <summary> /// Tapi控制类 /// </summary> public class ControlTapi { [DllImport("cellcore.dll")] private static extern int lineGetGeneralInfo(IntPtr hLigne,byte[]lpLineGeneralInfo ); /// <summary> /// 调用cellcore.dll获取sim卡的综合信息 /// </summary> /// <param name="l"></param> /// <returns></returns> private GeneralInfo GetGeneralInfo(Line l) { GeneralInfo lgi = new GeneralInfo(); byte[] buffer = new byte[512]; BitConverter.GetBytes(512).CopyTo(buffer, 0); if (lineGetGeneralInfo(l.hLine, buffer) != 0) { throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X")); } int subscsize = BitConverter.ToInt32(buffer, 44); int subscoffset = BitConverter.ToInt32(buffer, 48); lgi.SubscriberNumber = System.Text.Encoding.Unicode.GetString(buffer, subscoffset, subscsize).ToString(); lgi.SubscriberNumber = lgi.SubscriberNumber.Replace("\0", ""); return lgi; } /// <summary> /// 获取sim卡的IMSI /// </summary> /// <returns></returns> public static string GetIMSINumber() { string result = ""; try { Tapi t = new Tapi(); t.Initialize(); Line l = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, OpenNETCF.Tapi.LINECALLPRIVILEGE.MONITOR); ControlTapi ctapi = new ControlTapi(); GeneralInfo gi = ctapi.GetGeneralInfo(l); result = gi.SubscriberNumber; l.Dispose(); t.Shutdown(); } catch// (Exception ex) { result = ""; } return result; } /// <summary> /// 获取IMEI的号码 /// </summary> /// <returns></returns> public static string GetIMEINumber() { string result = ""; try { Tapi t = new Tapi(); t.Initialize(); Line l = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, OpenNETCF.Tapi.LINECALLPRIVILEGE.MONITOR); ControlTapi ctapi = new ControlTapi(); GeneralInfo gi = ctapi.GetGeneralInfo(l); result = gi.SerialNumber; l.Dispose(); t.Shutdown(); } catch// (Exception ex) { result = ""; } return result; } }
我是来求答案的。