首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> Tools SDK >> 正文
Obtain IMEI number of your symbian phone from Your Go-DB application
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:22:50

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


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.

相关文章:
How to retrieve the phone IMEI code on UIQ3.0
How to reset the alternate makmake entry in Codewarrior
Observer Pattern in Symbian application
Retrieving IMEI, IMSI, Network Info (Cell Id, Location Code) on 3rd Edition.
C++Programming Guidelines
C++ Inheritance
Why doesn't Symbian OS support writeable static data?
Tips & code samples for Sony Ericsson’s UIQ 3 based phones
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号