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
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|