How to retrive the IMSI number

From http://www.newlc.com/en/How-to-retrive-the-IMSI-number.html

 

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 structure of the IMSI is as follow:

MCC MNC MSIN

Where:
-  MCC is the Mobile Country Code which indicate from which country the SIM comes. This list of country code is defined in recommendation ITU E.212. You can get a list of these on Wikipedia
-  MNC is the Mobile Network Code and identifies the network operator (Orange, Vodafone, etc....). The link to the Wikipedia list of Mobile Network Code
-  MSIN is the Mobile Subscriber Identification Number which identifies the user (but is different from the phone number!).

UIQ platform

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:

 

Series 60 Platform

On the Series 60 platform, the same is possible for the phones that support the 3rd Party Telephony API (this means phones based on S60 v2 FP3 and later).

The IMSI can be obtained using the following code:

 

CTelephony telephony = CTelephony::NewL();
TRequestStatus status;
CTelephony::TSubscriberIdV1 subscriberId;
CTelephony::TSubscriberIdV1Pckg subscriberIdPckg(subscriberId);
telephony->GetSubscriberId(status, subscriberIdPckg));
User::WaitForRequest(status);
User::LeaveIfError(status);
TPtrC theIMSI(subscriberId.iSubscriberId);

RFs fs;
fs.Connect();
RFile file;

_LIT(KImsiFileName,"C://System//data//imsi.txt");

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"));
}
This tip was originally posted on SonyEricsson Developer Site for the UIQ version and on Symbian site for the Series 60 one
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值