Retrieve IMEI Through TAPI

Earlier I posted to the newsgroup a description of using Alex Feinman‘s Tapi Wrapper to retrieve the IMEI of the phone device. When I checked again, the specific required method is not included in the wrapper, however as Alex has made the line handles accessible it’s easy to tag functionality onto the library without re-inventing the wheel. I put together a VB example to P/Invoke the lineGetGeneralInfo method to retrieve information about the phone device. If you use this on a Smartphone device you may find it doesn’t work – this is because many Smartphone devices require signing to access many of the TAPI methods. I tested this on a HTC Phone Edition device (52.74 KB)


4 thoughts on “Retrieve IMEI Through TAPI”

  1. Hi. You might remember me from the newsgroups for asking this same question.

    Firstly, thanks for this example and it really helps in explaining the usage of TAPI.

    However, I am not using this for PPC so i ported the code to smartphone 2003 (I can zip up the project and send to you via email if you are able to help me personally) and put it on my smartphone.

    Now I understand that to access the TAPI on smartphone, my program would need to be signed with a privileged certificate.Since I installed the smartphone 2003 SDK, I took a look at the smartphone developer’s certificate. So i provisioned it to both my handphone and my PC registry. So the certificate reads "Smartphone Privileged Development Root for (my pc name)". I then sign both the TAPI dll and the exe file for the application with the certificate on my PC that reads ‘Smartphone Privileged Development Code-Signing for (my pc name)"

    I just transfer these files to my smartphone via activesync. I don’t make any cab files and when i run, it still gives me the message ‘the program comes from an unknown source and may not be trustworthy. do you want to run it bla bla bla". I am confused, didn’t i just sign the application? Anyway, when i try to get the IMEI and IMSI, it tries to load the DLL and the same ‘not trustworthy, unknown source’ message comes up. When I just press OK, i get ‘TAPI Error: 6’

    What is error 6? and what am i doing wrong? Is my code wrong or am i doing the whole code signing thing in a wrong way? I think the latter is true.

    I hope you can help me when you have the time. Thank you, Peter Foot, for your patience and this example and have a good day.


  2. Hi again.

    I tried to run the code on the emulator. The ‘TAPI Error: 6’ was returned at

    If lineGetGeneralInfo(l.hLine, buffer) <> 0 Then
    Throw New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"))
    End If

    I then did a "?lineGetGeneralInfo(1.hLine, buffer)" command and got "Method call did not return a value."

    So i changed the line

    Declare Function lineGetGeneralInfo Lib "cellcore.dll" (ByVal hLine As IntPtr, ByVal lpLineGeneralInfo As Byte()) As Integer


    System.Runtime.InteropServices.DllImport("cellcore.dll") _
    Private Shared Function lineGetGeneralInfo(ByVal hLine As IntPtr, ByVal lpLineGeneralInfo As Byte()) As Integer
    End Function
    (I had to remove the angle brackets in the above code because the script thought it was some html tag and decided to stop me from posting this message)

    When i ran the code again, there was an error at the same place. But this time, the error returned was "TAPI Error: 0". The command "lineGetGeneralInfo(l.hLine, buffer)" did not return anything as well.

    Could my problem be related to the way I am calling cellcore.dll ? Or is it that, the emulator cannot call cellcore.dll ?

    I hope this sheds a bit more light into the situation. Thank you.


  3. Hi Peter,

    I am also using Alex Feinman’s TAPI wrapper for C# (which has been very useful for me).
    Now I have to make a Call Forwarding (unconditional divert from my number to another one) and I find it very difficult to work with the function lineForward.

    Have you worked with this function from C#?
    Do you know how to build the LINEFORWARDLIST struct?
    Is anything neccesary in lphConsultCall and lphCallParams?

    Thanks in advance

Comments are closed.