Click here to Skip to main content
15,608,157 members
Please Sign up or sign in to vote.
1.55/5 (3 votes)
See more:
Hi to All,
How to get the Mobile IMEI Number using Tapi dll in dot net. I am new bie to mobile web site application. I need full flow of How to add the tapi in web application. If any other way to get mobile IMEI number please guide me. Thanks for your help.

1 solution

You can use the below method which now return a string which will be your IMEI.

example on how to call is
string myIMEIstring = getIMEIInfo();

internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);

// code to get IMEI
private string getIMEIInfo()
string IMEI;
Tapi t = new Tapi();

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)));

return (IMEI);
Share this answer
keerthana.k 9-Apr-14 2:02am    
Hi Guruprasad,
Above code worked on any os or else only windows os. Thanks for you reply.
Rage 9-Apr-14 4:44am    
You do realize that this code is exactly the same as the one I had posted, and that you have downvoted ?
keerthana.k 9-Apr-14 2:08am    
I got below the exception,
Type 'OpenNETCF.Tapi.LINEINITIALIZEEXPARAMS' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
Dinesh Raina 23-Jun-16 9:05am    
Hi Keerthana please check and use useragent
Guruprasad.K.Basavaraju 9-Apr-14 12:30pm    
Hi Keerthana,

I dont have the full code and may not be able exactly point out the issue for this, please see below for another article on a similar topic.. Are you looking to get this IMEI on a windows App ? where are you using this ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900