Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Tip us?
 
mjgermain
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 18
Join Date: Jan 2003
Location: Huddersfield UK
Default Getting IMEI within an EVC program

Does anyone know how to programmatically read the IMEI using embedded visual C. I have tried the TAPI lineGetGeneralInfo function but this always seems to return an error, as it requires TAPI extensions which don't seem to work. Is there any other function or API which returns this info?

Any help would be appreciated.
Regards

Malcolm Germain
Steve Old
#2  
Guest
Thanks Meter
Posts: n/a
You need to use the SimGetRecordInfo() function. The IMEI is stored at address 0x6F07.

Steve
 
mjgermain
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 18
Join Date: Jan 2003
Location: Huddersfield UK
Thanks,

However this is the Sim's IMSI (International Mobile Subs Identifier) which identifies the country and home network. I am trying to get the phone's IMEI which is the electronic serial no of the phone (to use as part of a secure https validation procedure).
Regards

Malcolm Germain
vpreHoose Old
#4  
Guest
Thanks Meter
Posts: n/a
Default IMEI Code

#include <TAPI.h>
#include <ExTAPI.h>

#define TAPI_VERSION_1_0 0x00010003
#define TAPI_VERSION_1_4 0x00010004
#define TAPI_VERSION_2_0 0x00020000

void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
void GetError(DWORD dwReturn);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HLINEAPP hLineAp = NULL;
DWORD dwNumDevs, dwDeviceID = 2;
HLINE hLine = NULL;

int i;
WCHAR szIMSI[180];
WCHAR szIMEI[180];

WCHAR szOutput[50];

LINEGENERALINFO lpLineInfo;
DWORD dwReturn, dwAPIVersion = TAPI_CURRENT_VERSION;

lineInitialize(&hLineAp, hInstance, lineCallbackFunc, NULL, &dwNumDevs);
lineNegotiateExtVersion(hLineAp, dwDeviceID, TAPI_VERSION_1_0, TAPI_CURRENT_VERSION, dwAPIVersion, NULL);
lineOpen(hLineAp, dwDeviceID, &hLine, dwAPIVersion, 0, 0, LINECALLPRIVILEGE_NONE, 0, 0);
lpLineInfo.dwTotalSize = 180;
dwReturn = lineGetGeneralInfo(hLine, &lpLineInfo);
if (!dwReturn)
{
if (lpLineInfo.dwSubscriberNumberSize > 2)
{
for (i = 0; i < (signed) lpLineInfo.dwSubscriberNumberSize/2; i++)
szIMSI[i] = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSubscriberNumberOffset/2);
szIMSI[i]=NULL;
MessageBox(NULL,szIMSI,_T(" IMSI"),MB_OK);
}
else
if (lpLineInfo.dwSubscriberNumberSize)
MessageBox(NULL,_T("Please Enter PIN"),_T(" IMSI"),MB_OK);
else
MessageBox(NULL,_T("No SIM Card Present"),_T(" IMSI"),MB_OK);

for (i = 0; i < (signed) (lpLineInfo.dwSerialNumberSize/2); i++)
szIMEI[i] = *((unsigned short *)(&lpLineInfo) + i + lpLineInfo.dwSerialNumberOffset/2);
szIMEI[i]=NULL;

wsprintf(szOutput,_T("NULL"));
MessageBox(NULL,szIMEI,_T(" IMEI"),MB_OK);
}
else
GetError(dwReturn);

lineClose(hLine);
lineShutdown(hLineAp);
return 0;
}

void CALLBACK lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance, DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
}

void GetError(DWORD dwReturn)
{
switch (dwReturn)
{
case LINEERR_RESOURCEUNAVAIL:
MessageBox(NULL,_T("No SIM Card"),_T("Error"),MB_OK);
break;
case LINEERR_INVALLINEHANDLE:
MessageBox(NULL,_T("Line Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_STRUCTURETOOSMALL:
MessageBox(NULL,_T("Oops"),_T(" Error"),MB_OK);
break;
case LINEERR_INVALPOINTER:
MessageBox(NULL,_T("Line Pointer Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_UNINITIALIZED:
MessageBox(NULL,_T("Radio Not Turned On"),_T(" Error"),MB_OK);
break;
case LINEERR_NOMEM:
MessageBox(NULL,_T("Out of Memory"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONUNAVAIL:
MessageBox(NULL,_T("Unavailable"),_T(" Error"),MB_OK);
break;
case LINEERR_OPERATIONFAILED:
MessageBox(NULL,_T("Please Turn Radio On"),_T(" Error"),MB_OK);
break;
default:
MessageBox(NULL,_T("Error"),_T(" Error"),MB_OK);
}
}
 
mjgermain
Old
#5  
Junior Member - OP
Thanks Meter 0
Posts: 18
Join Date: Jan 2003
Location: Huddersfield UK
Works great

Thanks

Regards

Malcolm Germain
Old
#6  
Guest
Thanks Meter
Posts: n/a
hi all, i tried to above code but it gave me thos following error !
any one can help me plz ?


unresolved external symbol lineGetGeneralInfo referenced in function WinMain



thankx alot
Old
#7  
Guest
Thanks Meter
Posts: n/a
hi alla again
these is nothing wrong else that i forgot to like the cellcore.lib lbrary to my project ops:
the code compiled but it gave me the result of " Unavailable " !
so how do i can get the IMEI ?
i'm using ROM 3.16.13 ENG


best regards

Essa
 
vpreHoose
Old
#8  
Senior Member
Thanks Meter 1
Posts: 100
Join Date: Jan 2003
Two possible answers:

A: Turn the phone on

B: HTC have changed the memory map allocation

I have some debug code behind the stuff I posted earlier to dump the entire contents of the lpLineInfo struct. i'l try and see what teh problem is.

On previous versions they omitted the IMEI or extended the HW id sections.
Essa Old
#9  
Guest
Thanks Meter
Posts: n/a
vpreHoose thanx alot for ur replay..
ur code is working fine the problem is that i didnt load the cellcore.lib for the evc compiler and the other problem is the DeviceID
in ur code u r using DeviceID = 2 while me i must use DeviceID = 0,
so i changed dwDeviceID = 2 to dwDeviceID = 0; and every thing is working fine

can u tell me how do i can get the caller number while mobile ringing ?
i would like to develope a software that assigne a ringing tone to each contact number.

thanx alot
 
vpreHoose
Old
#10  
Senior Member
Thanks Meter 1
Posts: 100
Join Date: Jan 2003
Yea, I was a little bit lazy not to write it to loop through all deviceid's...

:roll:

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Flash Custom ROM and Recovery to Samsung Galaxy S 4

After reading about Dan Rosenberg’s bootloader exploit for the Samsung Galaxy S 4,I … more

Windows-Based Multi-Tool for the Sony Xperia U

If you are a flashaholic and an owner of the Sony Xperia U, you may be interested in the … more

XDA University: Crafting Recovery-Flashable Packages

Those of us who use Linux on a day to day basis don’t think twice about sinking … more