Scalabium Software

SMReport Autogenerated
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
 
Metafile Convert
Fast Document Viewer
Paradox to Text converter
Mail parser (ActiveX)
Paradox Viewer
ABA Database Convert
Paradox to MS Access converter
DBISAM Viewer
SMReport
Database Information Manager
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

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

SMExport advertising