using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenNETCF.Tapi;
using System.Runtime.InteropServices ;
public partial class Mobile_mSource_Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string myIMEIstring = getIMEIInfo();
Label2.Text = "Mobile Number:" + myIMEIstring;
}
[DllImport("cellcore.dll")]
internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);
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];
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);
}
}