Obtain IMEI number of your symbian phone from Your Go-DB application
1 janv. 2005 - 12:08

Obtain IMEI number of your symbian phone from Your Go-DB application

Go-DB supports loading external DLLs via simple GBasic APIs. Although most of the widgets neccessary for business application development are avaiable in Go-DB, you may in certain cases want to extend a particular platform for reasons best suited for your requirement be it for your application related needs or simply having fun. Find out how to use Go-DB to obtain IMEI number(International Mobile Equipment Identity) from your Go-DB application. In a later article, i will explain how to send SMS from your Go-DB application from a Sony Ericsson p910i phone.

by Ted Daniel

Any cross platform application development at a particular point may need to extend a particular platform. Like any good cross platform development tool, Go-DB offers features which enable developers to fully extend a platform's full capability. This article focuses on certain APIs in GBasic and how to use them to hook your DLL built using Symbian SDK.

Step 1

You will need GStudio 3.4 final realease. Get a trial copy from http://www.go-db.com. You will also need Symbian module , which can be downloaded from the same location. NOTE: Symbian module needs GStudio pre-installed.

Step 2

Download and install a Symbian SDK. For this particular example any SDK for Symbian OS version 6.0 and above is needed. I have used UIQ 2.1 SDK wincw version, downloadable from Sony Ericsson developer site(http://developer.sonyericsson.com)

NOTE: You dont need to have Codewarrior to get this example working.

Step 3

Download the sources for this tutorial, downloadable with this article. Download and unzip to your Symbian install drive.Open a command prompt window and issue these commands.

bldmake bldfiles

abld build armi urel

This will buid the DLL. Pre-built SIS files are located in Group directory. SIS file installation will copy IMEIDLL.DLL to /system/libs directory on your device. Change the pkg file located in Group directory to suit your requirement.

Step 4

Build the Go-DB project in release mode. Create a SIS file for your device and install it. Click on "Fetch IMEI" button and a message box will pop-up displaying your device's IMEI number.

The Source code is as Follows

Listing 1. Symbian cpp source code

Our DLL exports one function whose definition is

EXPORT_C long GetIMEICode(char *str);

and the implementation is as follows

<TT>

EXPORT_C long GetIMEICode(char *str)
{
        int i= 0;
        TBuf<256> Path;
        TPlpVariantMachineId imei;
        PlpVariant::GetMachineIdL(imei);
        Path.Copy(imei);
        for(i=0;i <  Path.Length();i++)
        {
                str[i] = Path[i];
        }
        str[i] = '\0';
        return 1;
}
</TT>

Note that Go-DB understands "char *" only as parameters to functions.Converting to and from Symbian Descriptors is neccessary.After freezing the dll and building the project, note that a .DEF file will be created which will list the functions exported and theordinal associated with it.Our .DEF bundled with source shows the following.

EXPORTS

E32Dll__F10TDllReason @ 1 NONAME R3UNUSED ; E32Dll(TDllReason)

GetIMEICode__FPc @ 2 NONAME R3UNUSED ; GetIMEICode(char *)

We are not interested in E32Dll , just GetIMEICode. The ordinal as given to us is 2. This ordinal will be needed by our GBasic Code.

Note: To freeze a dll after exports have been identified and defined properly, issue this command

abld freeze armi

Listing 2. Go-DB source code

<TT>

Sub IMEICTRL_Click
        st1$="Initial String"
        h = loadlib("\\system\\libs\\IMEIDLL.dll")
        if h <> -1 then
                ret = calllibfunc(h,"2",st1$)
                msgbox("IMEI Code is " + st1$)
                unloadlib(h)
        else
                msgbox("Failed loading IMEIDLL.DLL")
        end if
End Sub
</TT>

We load the IMEIDLL first using loadlib function, if the function gets loaded properly, then the handle it returns will not be -1. Once we obtain the handle , use the handle in calllibfunc to execute the exported function. As explained in Listing 1, use "2" as Function Name. After the function call, st1$ will hold the IMEI number.

Fichier attachéTaille
Contains source code for the DLL and sample Go-DB project7.63 Ko
Tutorial posted janvier 1st, 2005 by teddaniel78

Soumis par John Gogal. (non vérifié) le mar, 2005-09-20 16:11.

Looks like the GStudio product was renamed to go-db itself. Can someone confirm pls?

Soumis par neel (non vérifié) le jeu, 2005-11-24 10:29.

Gstudio is the IDE, GBasic is the programming language, GSqllite is the embedded database --all these collectively packaged and branded as GoDB. The above three are the integral part of GoDB. In short, GoDB is a comprehensive development platform.

Soumis par Anonymous le mar, 2006-05-16 09:15.

Is it possible to retrieve the IMSI number of the SIM card using this programme? If possible what are the procedures to do so?

Soumis par moni4c le ven, 2007-10-26 08:08.

i got the imei number using the sample application given by the godb,
but i want to know the IMSI number......pls help......



copyright 2003-2009 NewLC SARL