begin process at 2010 07 29 15:11:25
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

PPC :: Trucs & Astuces

 > RÉCUPÉRER LES CODES IMEI, IMSI, OEM [MANAGED TAPI]

RÉCUPÉRER LES CODES IMEI, IMSI, OEM [MANAGED TAPI]


 Information sur la source

Note :
Aucune note
Catégorie :PPC :: Trucs & Astuces Source .NET ( DotNet ) Classé sous :TAPI, OEM, IMEI, IMSI, Modele Niveau :Initié Date de création :27/08/2008 Vu / téléchargé :14 107 / 350

Auteur : boutemine

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (7)
Ajouter un commentaire et/ou une note


 Description

Cliquez pour voir la capture en taille normale
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

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip Source avec une capture Source .NET (Dotnet) [.NET COMPACT FRAMEWORK] CLASSE SENDKEYS
Source avec Zip Source avec une capture Source .NET (Dotnet) [.NET COMPACT FRAMEWORK] CONNAÎTRE ET MODIFIER LE NIVEAU DE ...
Source avec Zip Source avec une capture Source .NET (Dotnet) [.NET COMPACT FRAMEWORK] UTILISER LA FENETRE CHOOSECONTACTDI...
Source .NET (Dotnet) [.NET COMPACT FRAMEWORK]PLANIFIER L'EXECUTION DE L'APPLICATI...
Source avec Zip Source avec une capture Source .NET (Dotnet) [.NET COMPACT FRAMEWORK] EFFECTUER DES APPELS TELEPHONIQUES.

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) CRÉER UN PLUG-IN TODAY AVEC LE FRAMEWORK CHRISTEK par MIMI361
RÉCUPÉRER DES VALEURS D'UNE LISTVIEW SOUS WINDOWS MOBILE par denischti59
Source .NET (Dotnet) JOUER UN FICHIER WAV SUR MULTI-PLATEFORMES DE PDA par BarresLTD
Source avec Zip Source avec une capture Source .NET (Dotnet) LECTURE DES INFORMATIONS DE LA MÉMOIRE par boutemine
Source avec Zip Source avec une capture Source .NET (Dotnet) AFFICHAGE/MASQUAGE DU CLAVIER SIP(SOFT INPUT PANEL) par boutemine

Commentaires et avis

Commentaire de madebyhisto le 28/11/2008 19:57:37

C'est bien mais comment peut ton faire pour faire marcher ce code pour un smarthphone au lieu d'un pocket ?

Commentaire de boutemine le 28/11/2008 22:07:51

Slt,
Tu change le type du projet seulement ;)

Commentaire de madebyhisto le 01/12/2008 20:34:19

Rebonjour Boutemine,

  L'idée est bonne mais ineficace. Lorsque je change de type de projet pour "Windows Mobile 6.0 Standard", lorsque je démarre l'appication j'ai un erreur d'opération et n'affiche rien par la suite comme données. Est-ce que tu as déjà fait du portage vers "WiMo 6 std" et as-tu dû modifier des paramètres.

Merci

Commentaire de boutemine le 01/12/2008 21:31:37

AH OK, j'ai compris, comme j'ai dis, il faut que l'application soit signé par un certificat car l'utilisation de l'API TAPI necessite des droits d'administration

http://boutemine-oualid.blogspot.com/2008/09/dveloppement-net-compact-framework-la.html

Commentaire de dvwyns le 06/02/2009 00:38:04

Bonjour boutemine,
Etant étudiant, je me vois mal acheter un certificat, donc si pas hasard tu aurais un système pour éviter cet achat et donc me permettre d'utiliser le code que tu proposes.
Je veux faire un antivol et j'ai donc besoin d'accéder au données système de la carte sim
Merci

Commentaire de boutemine le 06/02/2009 14:27:01

On est tous étudiants :)
Tu peux utiliser les certificats gratuit d'essai livrés avec le SDK
http://www.boutemine-oualid.qsh.me/post/Developpement-NET-Compact-Framework-LA-SECURITE-WINDOWS-MOBILE-6-ILLUSTREE-PAS-A-PAS.aspx

Commentaire de dvwyns le 07/02/2009 10:24:46

Bonjour boutemine,
C'est justement ce dont j'avais besoin...
Merci bcp pour ces renseignements précieux...

 Ajouter un commentaire


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


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Juillet 2010
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,780 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales