Accueil > > > RÉCUPÉRER LES CODES IMEI, IMSI, OEM [MANAGED TAPI]
RÉCUPÉRER LES CODES IMEI, IMSI, OEM [MANAGED TAPI]
Information sur la source
Description
J'ai créé un exemple sur l'utilisation de la bibliothèque TAPI pour récupérer des informations sur la machine Dans cette source: les informations à récupérer sont: La résolution horizontale (sans api). La résolution verticale (sans api). ------------------------------------- Utilis ation de la biblio TAPI pour récupérer: Le code IMEI (International Mobile Equipment Identity). Le code IMSI (International Mobile Subscriber Identity). L'OEM (Original Equipment Manufacturer). Le model de la machine. Le numéros de révision. --------------------------------------- J'ai inclus aussi le projet Tapi wrapper for managed code (Code source de la biblio Managed Tapi) Mais il y a quelques problèmes, L'application marche très bien avec les version Windows Mobile 2003 et (-) mais elle nécessite un certificat pour qu'elle marchera avec les versions 5 et 6 de Windows Mobile Donc il est necessaire d'obtenir un certificat et signer les deux projet (tapi et l'application qui l'utilise) pour l'executer. L'utilité du code, L'IMEI est généralement utiliser pour générer les cles des produits pour les sécuriser.
Source
- using System;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- using OpenNETCF.Tapi;
- // Référence a ajouter : Biblio TapiLib.dll
- namespace Tapi_IMEI_EMSI_OEM
- {
- public partial class frmMain : Form
- {
- // fonctions des dll PINVOKE.
- [DllImport("cellcore.dll")]
- internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);
- //OEM:pour Original Equipment Manufacturer
- //IMSI:pour International Mobile Subscriber Identity
- //IMEI:pour International Mobile Equipment Identity
- internal struct GeneralInfos
- {
- internal string OEM;
- internal string Model;
- internal string Revision;
- internal string IMEI;
- internal string IMSI;
- }
- public frmMain()
- {
- InitializeComponent();
- }
-
- static public String GetDisplayHorzRes()
- {
- return Screen.PrimaryScreen.Bounds.Width.ToString();
- }
- static public String GetDisplayVertRes()
- {
- return Screen.PrimaryScreen.Bounds.Height.ToString();
- }
-
-
- internal static GeneralInfos GetGeneralInfos()
- {
- //Creation d'un objet Tapi
- Tapi t = new Tapi();
- t.Initialize();
- //Objet line
- Line l = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);
- //Reservation d'un espace mémoire pour la lecture des infos.
- byte[] buffer = new byte[512];
- BitConverter.GetBytes(512).CopyTo(buffer, 0);
- // Lecture des infos, vérification du resultat de l'opération.
- 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"));
- }
- // preparations pour l'extraction des informations.
- GeneralInfos gi = new GeneralInfos();
-
- // OEM.
- int manuSize = BitConverter.ToInt32(buffer, 12);
- int manuOffset = BitConverter.ToInt32(buffer, 16);
- gi.OEM = System.Text.Encoding.Unicode.GetString(buffer, manuOffset, manuSize);
- gi.OEM = gi.OEM.Substring(0, gi.OEM.IndexOf(Convert.ToChar(0)));
-
- // Model
- int modelSize = BitConverter.ToInt32(buffer, 20);
- int modelOffset = BitConverter.ToInt32(buffer, 24);
- gi.Model = System.Text.Encoding.Unicode.GetString(buffer, modelOffset, modelSize);
- gi.Model = gi.Model.Substring(0, gi.Model.IndexOf(Convert.ToChar(0)));
-
- //Révision
- int revSize = BitConverter.ToInt32(buffer, 28);
- int revOffset = BitConverter.ToInt32(buffer, 32);
- gi.Revision = System.Text.Encoding.Unicode.GetString(buffer, revOffset, revSize);
- gi.Revision = gi.Revision.Substring(0, gi.Revision.IndexOf(Convert.ToChar(0)));
-
- //IMEI
- int IMEI = BitConverter.ToInt32(buffer, 36);
- int IMEIoffset = BitConverter.ToInt32(buffer, 40);
- gi.IMEI = System.Text.Encoding.Unicode.GetString(buffer, IMEIoffset, IMEI);
- gi.IMEI = gi.IMEI.Substring(0, gi.IMEI.IndexOf(Convert.ToChar(0)));
-
- //IMSI
- int IMSIsize = BitConverter.ToInt32(buffer, 44);
- int IMSIoffset = BitConverter.ToInt32(buffer, 48);
- gi.IMSI = System.Text.Encoding.Unicode.GetString(buffer, IMSIoffset, IMSIsize);
- gi.IMSI = gi.IMSI.Substring(0, gi.IMSI.IndexOf(Convert.ToChar(0)));
-
- l.Dispose();
- t.Shutdown();
- return gi;
- }
- private void frmMain_Load(object sender, EventArgs e)
- {
- GeneralInfos gi = GetGeneralInfos();
-
- lblHorizRes.Text += GetDisplayHorzRes();
- lblVertRes.Text += GetDisplayVertRes();
- lblIMEICode.Text += gi.IMEI;
- lblIMSICode.Text += gi.IMSI;
- lblOEM.Text += gi.OEM;
- lblModel.Text += gi.Model;
- lblRevision.Text += gi.Revision;
- }
-
- private void mnuQuit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using OpenNETCF.Tapi;
// Référence a ajouter : Biblio TapiLib.dll
namespace Tapi_IMEI_EMSI_OEM
{
public partial class frmMain : Form
{
// fonctions des dll PINVOKE.
[DllImport("cellcore.dll")]
internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);
//OEM:pour Original Equipment Manufacturer
//IMSI:pour International Mobile Subscriber Identity
//IMEI:pour International Mobile Equipment Identity
internal struct GeneralInfos
{
internal string OEM;
internal string Model;
internal string Revision;
internal string IMEI;
internal string IMSI;
}
public frmMain()
{
InitializeComponent();
}
static public String GetDisplayHorzRes()
{
return Screen.PrimaryScreen.Bounds.Width.ToString();
}
static public String GetDisplayVertRes()
{
return Screen.PrimaryScreen.Bounds.Height.ToString();
}
internal static GeneralInfos GetGeneralInfos()
{
//Creation d'un objet Tapi
Tapi t = new Tapi();
t.Initialize();
//Objet line
Line l = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);
//Reservation d'un espace mémoire pour la lecture des infos.
byte[] buffer = new byte[512];
BitConverter.GetBytes(512).CopyTo(buffer, 0);
// Lecture des infos, vérification du resultat de l'opération.
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"));
}
// preparations pour l'extraction des informations.
GeneralInfos gi = new GeneralInfos();
// OEM.
int manuSize = BitConverter.ToInt32(buffer, 12);
int manuOffset = BitConverter.ToInt32(buffer, 16);
gi.OEM = System.Text.Encoding.Unicode.GetString(buffer, manuOffset, manuSize);
gi.OEM = gi.OEM.Substring(0, gi.OEM.IndexOf(Convert.ToChar(0)));
// Model
int modelSize = BitConverter.ToInt32(buffer, 20);
int modelOffset = BitConverter.ToInt32(buffer, 24);
gi.Model = System.Text.Encoding.Unicode.GetString(buffer, modelOffset, modelSize);
gi.Model = gi.Model.Substring(0, gi.Model.IndexOf(Convert.ToChar(0)));
//Révision
int revSize = BitConverter.ToInt32(buffer, 28);
int revOffset = BitConverter.ToInt32(buffer, 32);
gi.Revision = System.Text.Encoding.Unicode.GetString(buffer, revOffset, revSize);
gi.Revision = gi.Revision.Substring(0, gi.Revision.IndexOf(Convert.ToChar(0)));
//IMEI
int IMEI = BitConverter.ToInt32(buffer, 36);
int IMEIoffset = BitConverter.ToInt32(buffer, 40);
gi.IMEI = System.Text.Encoding.Unicode.GetString(buffer, IMEIoffset, IMEI);
gi.IMEI = gi.IMEI.Substring(0, gi.IMEI.IndexOf(Convert.ToChar(0)));
//IMSI
int IMSIsize = BitConverter.ToInt32(buffer, 44);
int IMSIoffset = BitConverter.ToInt32(buffer, 48);
gi.IMSI = System.Text.Encoding.Unicode.GetString(buffer, IMSIoffset, IMSIsize);
gi.IMSI = gi.IMSI.Substring(0, gi.IMSI.IndexOf(Convert.ToChar(0)));
l.Dispose();
t.Shutdown();
return gi;
}
private void frmMain_Load(object sender, EventArgs e)
{
GeneralInfos gi = GetGeneralInfos();
lblHorizRes.Text += GetDisplayHorzRes();
lblVertRes.Text += GetDisplayVertRes();
lblIMEICode.Text += gi.IMEI;
lblIMSICode.Text += gi.IMSI;
lblOEM.Text += gi.OEM;
lblModel.Text += gi.Model;
lblRevision.Text += gi.Revision;
}
private void mnuQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Conclusion
Voici un article pour signer l'application http://msdn.microsoft.com/fr-fr/libr ary/ms839681(en-us).aspx
La biblio TapiLib est un wrapper pour c# et vb.net permettant l'utilisation de l'api native de téléphonie (Telephony API) mais son utilisation nécessite l'obtention d'un certificat. visiter le site http://www.mobile2market.net
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
imei sur hp ipaq 214 [ par lologuille ]
Bonjour, un logiciel me demande le code imei de mon hp ipaq 214. Y a-t-il un code imei sur cet appareil alors que ce n'est pas un téléphone!!!Merci d
|
Derniers Blogs
[WP7] AJOUTER DES IMAGES DANS LA MEDIA LIBRARY D'UN WINDOWS PHONE 7[WP7] AJOUTER DES IMAGES DANS LA MEDIA LIBRARY D'UN WINDOWS PHONE 7 par Audrey
L'émulateur Windows Phone 7, fourni avec la version Beta des outils développeurs n'inclut aucune image dans sa bibliothèque. Pas très pratique de tester son application lorsque l'on souhaite que l'utilisateur puisse choisir une image présente dans le télé...
Cliquez pour lire la suite de l'article par Audrey VIVE LES MOCKS ET LES POCOSVIVE LES MOCKS ET LES POCOS par vLabz
J'observe régulièrement autour de moi de la confusion à propos de ces deux termes et j'aimerais juste rappeler ce qu'ils signifient. Je ne suis bien sûr pas le mieux placé pour faire une leçon mais je vais faire de mon mieux pour mettre en valeur ce q...
Cliquez pour lire la suite de l'article par vLabz [WF4] WORKFLOW AND CUSTOM ACTIVITIES - BEST PRACTICES (4/5)[WF4] WORKFLOW AND CUSTOM ACTIVITIES - BEST PRACTICES (4/5) par JeremyJeanson
Vendredi dernier Microsoft a publié le quatrième épisode des bonnes pratiques pour coder ses activités custom dans WF4 : endpoint.tv - Workflow and Custom Activities - Best Practices (Part 4) . Tout comme pour les précédents épisodes, j'ai pris le temps d...
Cliquez pour lire la suite de l'article par JeremyJeanson DéVELOPPEMENT MOBILE : .NET COMPACT FRAMEWORK & LIMITATIONSDéVELOPPEMENT MOBILE : .NET COMPACT FRAMEWORK & LIMITATIONS par Pi-R
Introduction :
Le développement d'applications mobiles est quelque peu différent du développement d'applications sous Windows. En effet, le développement d'applications mobiles se base sur le .NET Compact Fra...
Cliquez pour lire la suite de l'article par Pi-R IPHONE VERSUS WP7 CODINGIPHONE VERSUS WP7 CODING par Nicolas
Je relais une présentation sur slideshare.net, qui compare le développement sur Iphone et Windows Phone 7, qui ma fait sourire. I phone versus windows phone 7 coding View more presentations from www.donburnett.com. J'aurais bien aimé une comparai...
Cliquez pour lire la suite de l'article par Nicolas
Forum
ECRAN ECRAN par calvine
Cliquez pour lire la suite par calvine
Logiciels
Xilisoft HD Vidéo Convertisseur 6 (6.0.3.0421)XILISOFT HD VIDéO CONVERTISSEUR 6 (6.0.3.0421)Xilisoft HD Vidéo Convertisseur est un outil professionnel de conversion HDTV, conçu pour transfo... Cliquez pour télécharger Xilisoft HD Vidéo Convertisseur 6 Xilisoft MP4 Convertisseur 6 (6.0.2.0415)XILISOFT MP4 CONVERTISSEUR 6 (6.0.2.0415)Xilisoft MP4 Convertisseur est un outil puissant pour la conversion de vidéo MP4, qui peut conver... Cliquez pour télécharger Xilisoft MP4 Convertisseur 6 Vade Retro Desktop (3.03)VADE RETRO DESKTOP (3.03)Le logiciel antispam Vade Retro pour Microsoft Outlook®, Outlook Express® et Windows Mail®(Vista)... Cliquez pour télécharger Vade Retro Desktop Malwarebytes Anti Malwares (1.46)MALWAREBYTES ANTI MALWARES (1.46)Malwarebytes' Anti-Malware est un anti-malware qui peut éliminer même les plus avancés des logic... Cliquez pour télécharger Malwarebytes Anti Malwares
|