GoDB Developer Network
Wednesday, November 30, 2005
  Obtain IMEI number of your symbian phone from Your Go-DB application

by Ted Daniel -- Source: www.newlc.com

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.

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 (now a newer version 3.6 is available for download) 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. (comes pre-installed with version 3.6. So no need to do this step)

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

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;

}


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

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

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.




GoDB-IMEI.zip
7.6 kb

 
Comments:
Thank you for the informative blog
Here Is some additional Sony Ericsson Cell phone resources with reviews and features for
Sony Ericsson Cell Phones if you or your readers are interested
 
Post a Comment

Links to this post:

Create a Link



<< Home
Welcome to the unofficial GoDB Developer Network. This blog is completely dedicated to GoDB platform -- a multi platform Mobile RAD tool for developing handheld and wireless applications for Windows Mobile (Pocket PC,Win CE, Smartphones), Palm, Symbian, Embedded Linux, Linux, Win 32, etc. Fellow GoDB developers can find sample codes, contribute to the blog and Mobility related news for the benefit of the mobile development community as a whole.

ARCHIVES
2005-11-20 / 2005-11-27 / 2005-12-04 / 2005-12-11 / 2006-11-05 /


Powered by Blogger