Click here to Skip to main content
14,639,056 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 2

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);
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 ?
keerthana.k 10-Apr-14 5:16am
Hi Guruprasad,
I did not use the windows apps but i got the code from net and i tried only. I need to get unique id from mobile.I developed a website using That unique id stored in database.Can you please help me. Thanks for advance.
Guruprasad.K.Basavaraju 10-Apr-14 10:40am
Keerthana, you cannot get the IMEI from a webpage for security reasons..
Pranita Gupta 11-Apr-15 6:34am
i have imei number and mobile number of user...i want to search device on google maps by imei number using would u help me....
Member 12279986 22-Jan-16 5:54am
please in visual basic commands

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100