Link to home
Start Free TrialLog in
Avatar of Kani Str
Kani StrFlag for India

asked on

detect IMEI number

i need to find the imei number proramatically, possible? if so how? I'm using VS 2005 and VB
Avatar of Kani Str
Kani Str
Flag of India image

ASKER

windows 2003 mobile.
ASKER CERTIFIED SOLUTION
Avatar of CraigTheGeek
CraigTheGeek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
here is the working code...


Dim t As New OpenNETCF.Tapi.Tapi
            t.Initialize()

            Dim l As OpenNETCF.Tapi.Line = t.CreateLine(0, OpenNETCF.Tapi.LINEMEDIAMODE.INTERACTIVEVOICE,

OpenNETCF.Tapi.LINECALLPRIVILEGE.MONITOR)

            Dim lgi As New GeneralInfo

            Dim buffer(512) As Byte
            'write size
            BitConverter.GetBytes(512).CopyTo(buffer, 0)

            If lineGetGeneralInfo(l.hLine, buffer) <> 0 Then
                Throw New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI

Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"))
            End If

            Dim serialsize As Integer = BitConverter.ToInt32(buffer, 36)
            Dim serialoffset As Integer = BitConverter.ToInt32(buffer, 40)
            lgi.SerialNumber = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize)
            lgi.SerialNumber = lgi.SerialNumber.Substring(0, lgi.SerialNumber.IndexOf(Chr(0)))

            ' Dim gi As GeneralInfo = GetGeneralInfo(l)
            'lblManufacturer.Text = gi.Manufacturer
            'lblModel.Text = gi.Model
            ' lblRevision.Text = gi.Revision
            ' lblSubscriber.Text = gi.SubscriberNumber
            l.Dispose()
            t.Shutdown()
            Return lgi.SerialNumber