【问题标题】:Getting IMEI number in windows phone 7 [duplicate]在Windows Phone 7中获取IMEI号码[重复]
【发布时间】:2011-11-17 14:41:09
【问题描述】:

可能重复:
Find IMEI no in wp7?

在 windows phone 7 中是否有任何 api 可以获取设备 IMEI 号,我可以通过使用 DeviceExtendedProperties.GetValue("DeviceUniqueId") 获取它“设备唯一 ID”,但我需要获取 IMEI。

【问题讨论】:

    标签: windows-phone-7 imei


    【解决方案1】:

    cc:http://www.cnblogs.com/xjb/archive/2007/02/05/640360.html

    以下代码未经我测试。

    public struct GeneralInfo
    {
        public string Manufacturer;
        public string Model;
        public string Revision;
        public string SerialNumber;
        public string SubscriberNumber;
    }
    
    /// <summary>
    /// Tapi control class
    /// </summary>
    public class ControlTapi
    {
    
        [DllImport("cellcore.dll")]
        private static extern int lineGetGeneralInfo(IntPtr hLigne,byte[]lpLineGeneralInfo );
    
        /// <summary>
        /// Invoke cellcore.dll to get info of 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>
        /// GET IMSI of SIM Card
        /// </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>
        /// Get 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;
        }
    
    }
    

    【讨论】:

    • Thnx for d 回复 Ming,我只是想知道 Tapi 是第三方 API 还是微软原生 API?
    • 这适用于 Windows Mobile,而不是 Windows Phone 7。
    • @Matt:如果是这样,我不会对我有任何用处..你能建议一些其他解决方法吗..
    • @Vaibhav 访问 IMEI 号码不适用于 WP7 上的开发人员/应用程序
    猜你喜欢
    • 1970-01-01
    • 2022-01-19
    • 2012-02-03
    • 2017-12-16
    • 2012-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多