使用C#或VB .net获取移动设备的IMEI或唯一序列号 [英] Get IMEI or Unique Serial number of mobile device using C# or VB .net

查看:574
本文介绍了使用C#或VB .net获取移动设备的IMEI或唯一序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何使用dot net中的Tapi dll获取移动IMEI号码。我是移动网站应用的新手。我需要完整的流程如何在asp.net Web应用程序中添加tapi。如果有任何其他方式获取移动IMEI号码,请指导我。感谢您的帮助。

Hi to All,
How to get the Mobile IMEI Number using Tapi dll in dot net. I am new bie to mobile web site application. I need full flow of How to add the tapi in asp.net web application. If any other way to get mobile IMEI number please guide me. Thanks for your help.

推荐答案

您可以使用以下方法返回一个字符串,该字符串将成为您的IMEI。



关于如何调用的示例

You can use the below method which now return a string which will be your IMEI.

example on how to call is
string myIMEIstring = getIMEIInfo();







[DllImport("cellcore.dll")]
internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);

// code to get IMEI
private string getIMEIInfo()
{
string IMEI;
Tapi t = new Tapi();
t.Initialize();
Line _line = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);

byte[] buffer = new byte[512];
//write size
BitConverter.GetBytes(512).CopyTo(buffer, 0);

if (lineGetGeneralInfo(_line.hLine, buffer) != 0)
{
throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"));
}

int serialsize = BitConverter.ToInt32(buffer, 36);
int serialoffset = BitConverter.ToInt32(buffer, 40);
IMEI = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize);
IMEI = IMEI.Substring(0, IMEI.IndexOf(Convert.ToChar(0)));


_line.Dispose();
t.Shutdown();
return (IMEI);
}


这篇关于使用C#或VB .net获取移动设备的IMEI或唯一序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆