Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips


#1: How can I read the IMEI in Compact .NET?

//Import cellcore.dll
 
[DllImport("cellcore.dll")]
 internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);
 
// code to get IMEI
private void getIMEIInfo()
{
string IMEI;
Tapi t = new Tapi();
t.Initialize();
Line _line = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);
 
byte[] buffer = new byte[512];
//write size
BitConverter.GetBytes(512).CopyTo(buffer, 0);
 
if (lineGetGeneralInfo(_line.hLine, buffer) != 0)
{
throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"));
}
 
int serialsize = BitConverter.ToInt32(buffer, 36);
int serialoffset = BitConverter.ToInt32(buffer, 40);
IMEI = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize);
IMEI = IMEI.Substring(0, IMEI.IndexOf(Convert.ToChar(0)));
 
AppSettings.SetIMEI(IMEI);
_line.Dispose();
t.Shutdown();
}

To get the TAPILib: http://www.alexfeinman.com/download.asp?doc=tapi1.1.zip


Published: November 13, 2008

See also
 
Paradox to MS Access converter
Clarion to Text converter
Viewer for MS Outlook Messages
SMMsg suite
ABA Picture Convert
Word Web-stream
Protected Storage Viewer
Database Information Manager
SMReport
ExcelFile Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2025, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising