Header Sep
Symbian OS Tips, Tricks & Code
Score
Login to rate page
 
June 2004
Obtaining the IMSI number on P800 and P900

[Back]

IMSI is an abbreviation for "International Mobile Subscriber Identity". The IMSI number is a unique 15-digit code that is attached to every SIM (Subscriber Identification Module) card and makes it possible for mobile networks to identify the home country and network of a subscriber.

The IMSI number can be obtained from Sony Ericsson P800 and P900 smartphones for use in C++ applications by reading the contents of the file
     C:\System\data\imsi.txt

This file will be updated automatically if the SIM card is changed.

Some system processes keep this file open and therefore the file needs to be opened in shared mode for readers. This is done by using the EFileShareReadersOnly flag when opening the file. The following C++ code reads the contents of imsi.txt and displays it on the screen:

RFs fs;
fs.Connect();
RFile file;
 
_LIT(KImsiFileName,"javascript:void(null);");
 
TInt res = file.Open(fs,KImsiFileName,
  EFileShareReadersOnly|EFileStreamText);
 
if(res != KErrNone)
{
  gConsole->Printf(_L("Open failed: %d\n"),res);
}
else
{
  TBuf8<128> buf; 
  file.Read(buf);
  file.Close();
  fs.Close();

  TBuf<128> printBuf;
  printBuf.Copy(buf);
  gConsole->Printf(_L("IMSI: "));
  gConsole->Printf(printBuf);   
  gConsole->Printf(_L("\n"));
}

 

Score
Login to rate page