• Anasayfa
  • Hakkımızda
  • Etkinlikler
  • Destek Verin
  • Site Haritası
  • Giriş Yap
  • Üye Ol
  • Facebook
  • Twitter
  • RSS
Yazılım Dilleri
  • Soru - Cevap
  • EĞİTİM SETİ
  • KATEGORİ
  • DUYURU
  • TEKNOLOJİ HABERLERİ

Son Sorular

  • 23.04.2016 00:55:33C programlama 2 oyun
  • 20.04.2016 16:34:41Local Database
  • 15.04.2016 14:26:15Fatura kayıt işlemi
  • 21.03.2016 01:55:30C# problem

Popüler Sorular

  • 27.05.2012 05:49:50Asp.Net ile Date time alana veri ekleyemiiyorum ?
  • 2.04.2012 00:45:18.exe uzantılı dosya için dijital imza nerde nasıl alınır.
  • 12.05.2012 08:44:49Acil Yardım
  • 27.05.2012 13:46:51veri tabanı bağlantısı
  • .Net Framework
  • 8085 Assembly
  • Active Directory
  • ADO.NET
  • Android
  • Apple IOS
  • Arduino
  • ASP.NET
  • ASP.NET MVC
  • Blackberry
  • C#.Net
  • C++
  • CCG Framework
  • CISCO
  • CSS
  • Diğer
  • Dreamweaver
  • Entity Framework
  • Exchange Server
  • Gömülü Sistemler
  • GSM Programlama
  • Güncel
  • Güvenlik
  • HTML5
  • Java
  • Javascript / JQuery
  • Jira
  • Kariyer ve İş Yaşamı
  • LINQ
  • LibreOffice
  • Linux
  • Matlab
  • Microsoft Dynamics CRM
  • Mobil Uygulama Geliştirme
  • MySQL
  • NoSQL
  • Oracle
  • OWIN
  • PFSense
  • PHP
  • Powershell
  • Python
  • Sanallastirma
  • SAP-ABAP
  • SCOM 2012
  • SEO
  • Sharepoint 2010
  • Sharepoint 2013
  • Silverlight
  • Sistem Analiz ve Tasarımı
  • SQL Server
  • Symantec
  • TFS
  • T-SQL
  • Ubuntu
  • VB.NET
  • Veritabanı Yönetim Sistemleri
  • Visual Studio
  • VMware
  • WCF
  • Web Hosting
  • Windows 8
  • Windows Azure
  • Windows Phone 7.1
  • Windows Phone 8
  • Windows Server
  • Wordpress
  • WPF
  • Xamarin
  • XNA
  • Yazılım Mühendisliği
  • Yöneylem Araştırması
  • ASP.NET MVC
  • Entity Framework
  • Javascript / JQuery
  • LINQ
  • PHP

Son Duyurular

IPhone 6 ve IPhone 6 Plus Teknik Özellikleri ve Fiyatı

IPhone 6 ve IPhone 6 Plus Teknik Özellikleri ve Fiyatı

DELL'in Yeni Projesi: USB Bilgisayar (Project Ophelia)

DELL'in Yeni Projesi: USB Bilgisayar (Project Ophelia)

Windows Phone Youtube Uygulaması Google ve Microsoft ile Yeniden Yapılıyor

Windows Phone Youtube Uygulaması Google ve Microsoft ile Yeniden Yapılıyor

Android ve Apple IOS Telefonlar için Blackberry Messenger (BBM)

Android ve Apple IOS Telefonlar için Blackberry Messenger (BBM)

Nokia Lumia 925 Teknik Özellikleri, Lumia 928 ve 920 ile Karşılaştırması

Nokia Lumia 925 Teknik Özellikleri, Lumia 928 ve 920 ile Karşılaştırması

LG Optimus G Pro Özellikleri ve Gözle Video Oynatma Teknolojisi

LG Optimus G Pro Özellikleri ve Gözle Video Oynatma Teknolojisi

Windows Mobile Cihazların UUID ve IMEI Numaralarını Bulma

Windows mobile cihazların UUID ve IMEI numaraları nasıl bulunur öğrenelim.

16.08.2013

Yazar: Serkan Özcan (Google+)

Kategori: .Net Framework

3386

Windows pocket pc, pda, mobile cihazlarda cihazın kendine özgü numarasını bulmak için compact işletim sistemindeki coredll.dll dosyası kullanılır. Bu dosyayı kullanan ve GetDeviceID, GetIMEI metodları olan DeviceInfo sınıfını ve örnek kullanımını aşağıda paylaşıyorum.

string dvcID = DeviceInfo.GetDeviceID();
string dvcIMEI = DeviceInfo.GetIMEI();

 

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
 
namespace SerkanOzcan
{
    public class DeviceInfo
    {
 
        [DllImport("coredll.dll")]
        private static extern bool KernelIoControl(Int32 IoControlCode, IntPtr
          InputBuffer, Int32 InputBufferSize, byte[] OutputBuffer, Int32
          OutputBufferSize, ref Int32 BytesReturned);
 
        private static Int32 FILE_DEVICE_HAL = 0x00000101;
        private static Int32 FILE_ANY_ACCESS = 0x0;
        private static Int32 METHOD_BUFFERED = 0x0;
 
        private static Int32 IOCTL_HAL_GET_DEVICEID =
        ((FILE_DEVICE_HAL) << 16) | ((FILE_ANY_ACCESS) << 14)
         | ((21) << 2) | (METHOD_BUFFERED);
 
 
        public static string GetDeviceID()
        {
            byte[] OutputBuffer = new byte[256];
            Int32 OutputBufferSize, BytesReturned;
            OutputBufferSize = OutputBuffer.Length;
            BytesReturned = 0;
 
            bool retVal = KernelIoControl(IOCTL_HAL_GET_DEVICEID, 
                    IntPtr.Zero,
                    0,
                    OutputBuffer,
                    OutputBufferSize,
                    ref BytesReturned);
 
            if (retVal == false)
            {
                return null;
            }
 
            Int32 PresetIDOffset = BitConverter.ToInt32(OutputBuffer, 4); 
            Int32 PlatformIDOffset = BitConverter.ToInt32(OutputBuffer, 0xc);
            Int32 PlatformIDSize = BitConverter.ToInt32(OutputBuffer, 0x10);
 
            StringBuilder sb = new StringBuilder();
 
            for (int i = PresetIDOffset;
                 i < PlatformIDOffset + PlatformIDSize;
                 i++)
            {
                sb.Append(String.Format("{0:X2}", OutputBuffer[i]));
            }
 
 
            return sb.ToString();
        }
 
        [DllImport("coredll")]
        public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int lpdwNumDevs, ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);
 
        [DllImport("coredll")]
        public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, IntPtr lpCallParams);
 
        [DllImport("coredll")]
        public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int lpdwAPIVersion, out LINEEXTENSIONID lpExtensionId);
 
        [DllImport("cellcore")]
        public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes);
 
        [DllImport("cellcore")]
        public static extern int lineGetGeneralInfo(IntPtr hLine, ref LINEGENERALINFO lineGenerlInfo);
 
        [DllImport("coredll")]
        public static extern int lineClose(IntPtr hLine);
 
        [DllImport("coredll")]
        public static extern int lineShutdown(IntPtr m_hLineApp);
 
        public static string GetIMEI()
        {
            IntPtr hLine;
            int dwNumDev;
            int num1 = 0x20000;
            LINEINITIALIZEEXPARAMS lineInitializeParams = new LINEINITIALIZEEXPARAMS();
            lineInitializeParams.dwTotalSize = (uint)Marshal.SizeOf(lineInitializeParams);
            lineInitializeParams.dwNeededSize = lineInitializeParams.dwTotalSize;
            lineInitializeParams.dwOptions = 2;
            lineInitializeParams.hEvent = IntPtr.Zero;
            lineInitializeParams.hCompletionPort = IntPtr.Zero;
 
            int result = lineInitializeEx(out hLine, IntPtr.Zero,
            IntPtr.Zero, null, out dwNumDev, ref num1, ref lineInitializeParams);
            if (result != 0)
            {
                throw new ApplicationException(string.Format("lineInitializeEx failed!\n\nError Code:{0}", result.ToString()));
            }
 
            int version;
            int dwAPIVersionLow = 0x10004;
            int dwAPIVersionHigh = 0x20000;
            LINEEXTENSIONID lineExtensionID;
            result = lineNegotiateAPIVersion(hLine, 0, dwAPIVersionLow, dwAPIVersionHigh, out version, out lineExtensionID);
            if (result != 0)
            {
                throw new ApplicationException(string.Format("lineNegotiateAPIVersion failed!\n\nError Code: {0}", result.ToString()));
            }
 
            IntPtr hLine2 = IntPtr.Zero;
            result = lineOpen(hLine, 0, out hLine2, version, 0, IntPtr.Zero, 0x00000002, 0x00000004, IntPtr.Zero);
            if (result != 0)
            {
                throw new ApplicationException(string.Format("lineNegotiateAPIVersion failed!\n\nError Code: {0}", result.ToString()));
            }
 
            int structSize = Marshal.SizeOf(new LINEGENERALINFO());
            byte[] bytes = new byte[structSize];
            byte[] tmpBytes = BitConverter.GetBytes(structSize);
 
            for (int index = 0; index < tmpBytes.Length; index++)
            {
                bytes[index] = tmpBytes[index];
            }
 
            result = lineGetGeneralInfo(hLine2, bytes);
 
            // get the needed size
            int neededSize = BitConverter.ToInt32(bytes, 4);
 
            // resize the array
            bytes = new byte[neededSize];
 
            // write out the new allocated size to the byte stream
            tmpBytes = BitConverter.GetBytes(neededSize);
            for (int index = 0; index < tmpBytes.Length; index++)
            {
                bytes[index] = tmpBytes[index];
            }
 
            // fetch the information with properly size buffer
            result = lineGetGeneralInfo(hLine2, bytes);
 
            if (result != 0)
            {
                throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
            }
 
            int size;
            int offset;
 
            //// manufacture
            //size = BitConverter.ToInt32(bytes, 12);
            //offset = BitConverter.ToInt32(bytes, 16);
            //string manufacturer = Encoding.Unicode.GetString(bytes, offset, size);
            //manufacturer = manufacturer.Substring(0, manufacturer.IndexOf('\0'));
 
            //// model
            //size = BitConverter.ToInt32(bytes, 20);
            //offset = BitConverter.ToInt32(bytes, 24);
            //string model = Encoding.Unicode.GetString(bytes, offset, size);
            //model = model.Substring(0, model.IndexOf('\0'));
 
            //// revision
            //size = BitConverter.ToInt32(bytes, 28);
            //offset = BitConverter.ToInt32(bytes, 32);
            //string revision = Encoding.Unicode.GetString(bytes, offset, size);
            //revision = revision.Substring(0, revision.IndexOf('\0'));
 
            // serial number
            size = BitConverter.ToInt32(bytes, 36);
            offset = BitConverter.ToInt32(bytes, 40);
            string serialNumber = Encoding.Unicode.GetString(bytes, offset, size);
            serialNumber = serialNumber.Substring(0, serialNumber.IndexOf('\0'));
 
            //// subscriber id
            //size = BitConverter.ToInt32(bytes, 44);
            //offset = BitConverter.ToInt32(bytes, 48);
            //string subsciberId = Encoding.Unicode.GetString(bytes, offset, size);
            //subsciberId = subsciberId.Substring(0, subsciberId.IndexOf('\0'));
 
 
            //tear down
            lineClose(hLine2);
            lineShutdown(hLine);
 
            return serialNumber;
        }
 
    }
 
    public class LINEGENERALINFO
    {
        public int dwManufacturerOffset;
        public int dwManufacturerSize;
        public int dwModelOffset;
        public int dwModelSize;
        public int dwNeededSize;
        public int dwRevisionOffset;
        public int dwRevisionSize;
        public int dwSerialNumberOffset;
        public int dwSerialNumberSize;
        public int dwSubscriberNumberOffset;
        public int dwSubscriberNumberSize;
        public int dwTotalSize;
        public int dwUsedSize;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct LINEEXTENSIONID
    {
        public IntPtr dwExtensionID0;
        public IntPtr dwExtensionID1;
        public IntPtr dwExtensionID2;
        public IntPtr dwExtensionID3;
    }
 
    [StructLayout(LayoutKind.Sequential)]
    public struct LINEINITIALIZEEXPARAMS
    {
        public uint dwTotalSize;
        public uint dwNeededSize;
        public uint dwUsedSize;
        public uint dwOptions;
        public System.IntPtr hEvent;
        public System.IntPtr hCompletionPort;
        public uint dwCompletionKey;
    }
}

 

Yazar Hakkında

Serkan Özcan

Serkan Özcan

serkanozcan.com

SAP ABAP Danışmanı & Mobil Çözümler Uzmanı olan Serkan Özcan iş hayatına Haziran 2008’de Arista Danışmanlık Şirketi’nde abap danışmanı olarak başlayıp mobil takım liderliği de yaptıktan sonra Ocak 2013’te BTC-AG Bilişim Hizmetleri A.Ş’ye geçti. Danışmanlık kariyeri boyunca çeşitli sektörlerde SAP modüllerinde ve teknik konularda danışman olarak görev aldı. Uzun soluklu projelerde hem analizlere katıldı hem de uygulama geliştirdi. Ayrıca birçok projede kısa süreli çalışmalarda bulundu. SAP ve Non-SAP sistemler arasındaki entegrasyonlar için çeşitli arayüzler geliştirdi. Microsoft Vb.net, C# dillerini kullanarak mobil saha uygulamaları tasarladı ve programladı. Iphone-Ipad-SAP entegrasyonunu içeren IOS projelerinin tasarlanıp geliştirilmesi ve programlanması görevini üstlendi.

Sosyal Medya

ORANLAR

  • 3386izleme

Arkadaşlarınla Paylaş

  • Tweet

0 Yorum

Yorum Yaz / Soru Sor

Lütfen yorum yazmak veya soru sormak için üye girişi yapınız.

Son Yorumlar

  • Böyle bir sayfalama ağ trafiğini hafifleti...
  • Merhaba, ellerinize sağlık çok yardımcı ol...
  • Merhaba Bu uygulama örneğinden ASP.net ...
  • Hocam Link başka sayfaya yönlendiriyor.
  • merhaba benim merak ettiğim bir konu var y...

En Güncel Sorular

  • Bilgilendirme maili (C#.Net)
  • Power Pivot (Sharepoint 2010)
  • BigInteger, BigDecimal (Asp.Net ve Asp.Net MVC)
  • visual C# ile asp nette veritabanı islemleri (Asp.Net ve Asp.Net MVC)
  • Share Point ile Dosya Arşiv Yönetim Sistemi yapılabilir mi ? (Sharepoint 2010)

En Son Cevap Verilen Sorular

  • Bilgilendirme maili
  • BigInteger, BigDecimal
  • visual C# ile asp nette veritabanı islemleri
  • Share Point ile Dosya Arşiv Yönetim Sistemi yapılabilir mi ?
  • txt dosyasına veri yazma

Twitter

Takip et: @yazilim_dilleri

En Çok Okunanlar

Elif BAYRAKDAR

C# ile SQL Server Bağlantısı, Insert, Update ve Delete Sorguları

23.05.2013

  • 122032
  • 0
Hakan Keskin

C# ile Windows Service Projesi Oluşturma, Debug Etme ve Setup Hazırlama

17.12.2013

  • 68134
  • 0
batuhan avlayan

Php - Mail Gönderme (İletişim Formu)

02.09.2013

  • 49928
  • 0

Sponsorlar

KODLAB
Pluralsight
Exchange server is
Office 365
YAZILIM DİLLERİ
Yukarı Çık
  • Hakkımızda
  • Facebook
  • Twitter
  • RSS

© Yazılım Dillerinin Buluşma Noktası | Kaynak belirtildiği sürece makaleler kopyalanabilir.
YazilimDilleri.Net sitesinde yer alan kullanıcıların oluşturduğu tüm içeriklerin yayınlanması ile ilgili yasal yükümlülükler içeriği oluşturan kullanıcıya aittir, YazilimDilleri.Net hiçbir şekilde sorumlu değildir.

Kapat

Giriş Yap

Kullanıcı Adı

Şifre

Şifremi Unuttum

KULLANICI GİRİŞİ