資源簡介
c#獲取mobile手機的IMEI和IMSI!
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.Runtime.InteropServices;
using?OpenNETCF.Tapi;
namespace?IMEIIMSI
{
????class?ControlTapi
????{
????????public?struct?GeneralInfo
????????{
????????????public?string?Manufacturer;
????????????public?string?Model;
????????????public?string?Revision;
????????????public?string?SerialNumber;
????????????public?string?SubscriberNumber;
????????}
????????[DllImport(“cellcore.dll“)]
????????private?static?extern?int?lineGetGeneralInfo(IntPtr?hLigne?byte[]?lpLineGeneralInfo);
????????///????
????????///?調用cellcore.dll獲取sim卡的綜合信息和imei碼???
????????///? ???
????????///????
????????///? ???
????????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“?““);
????????????int?serialsize?=?BitConverter.ToInt32(buffer?36);
????????????int?serialoffset?=?BitConverter.ToInt32(buffer?40);
????????????lgi.SerialNumber?=?System.Text.Encoding.Unicode.GetString(buffer?serialoffset?serialsize);
????????????lgi.SerialNumber?=?lgi.SerialNumber.Substring(0?lgi.SerialNumber.IndexOf(‘\0‘));
????????????return?lgi;
????????}
????????///????
????????///?獲取IMEI的號碼???
????????///? ???
????????///? ???
????????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();
????????????????return?result;
????????????}
????????????catch?(Exception)
????????????{
????????????????result?=?““;
????????????}
????????????return?result;
????????}
????????///????
????????///?獲取sim卡的IMSI???
????????///? ???
????????///? ???
????????public?static?string?GetIMSINumber()
????????{
????????????string?resu
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5618??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\Properties\Resources.resx
?????文件???????1246??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\Properties\AssemblyInfo.cs
?????文件???????2351??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\Properties\Resources.Designer.cs
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\Properties
?????文件??????61440??2010-11-04?13:14??IMEIIMSI\IMEIIMSI\TapiLib.dll
?????文件???????6300??2010-11-04?13:01??IMEIIMSI\IMEIIMSI\Form1.resx
?????文件???????4493??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\IMEIIMSI.csproj
?????文件??????61440??2010-11-04?13:14??IMEIIMSI\IMEIIMSI\bin\IMEIIMSI\TapiLib.dll
?????文件???????8192??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\bin\IMEIIMSI\IMEIIMSI.exe
?????文件??????22016??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\bin\IMEIIMSI\IMEIIMSI.pdb
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\bin\IMEIIMSI
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\bin
?????目錄??????????0??2010-11-04?12:42??IMEIIMSI\IMEIIMSI\obj\Debug\TempPE
?????文件????????180??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\Debug\IMEIIMSI.Form1.resources
?????文件????????180??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\Debug\IMEIIMSI.Properties.Resources.resources
?????文件????????842??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\Debug\IMEIIMSI.csproj.GenerateResource.Cache
?????文件??????22016??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\Debug\IMEIIMSI.pdb
?????文件???????8192??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\Debug\IMEIIMSI.exe
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\obj\Debug
?????文件????????298??2010-11-04?13:24??IMEIIMSI\IMEIIMSI\obj\IMEIIMSI.csproj.FileList.txt
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\obj
?????文件???????3803??2010-11-04?13:01??IMEIIMSI\IMEIIMSI\Form1.Designer.cs
?????文件????????871??2010-11-04?13:22??IMEIIMSI\IMEIIMSI\Form1.cs
?????文件??????10752??2010-11-04?13:14??IMEIIMSI\IMEIIMSI\BeeMobile.Utils.dll
?????文件???????3663??2010-11-04?13:20??IMEIIMSI\IMEIIMSI\ControlTapi.cs
?????文件????????364??2010-11-04?12:41??IMEIIMSI\IMEIIMSI\Program.cs
?????文件????????243??2010-11-04?13:20??IMEIIMSI\IMEIIMSI\IMEIIMSI.csproj.user
?????目錄??????????0??2010-11-04?12:41??IMEIIMSI\IMEIIMSI
?????文件???????1079??2010-11-04?13:20??IMEIIMSI\IMEIIMSI.sln
????..A..H.?????15360??2010-11-04?13:20??IMEIIMSI\IMEIIMSI.suo
............此處省略4個文件信息
- 上一篇:C#實現簡單QQ聊天程序
- 下一篇:語音播報系統叫號系統的
評論
共有 條評論