Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

在3版中获取设备IMEI码

From Wiki
Jump to: navigation, search
Article Metadata

文章
User:Davey 2 在 09 Jan 2008 创建
最后由 hamishwillee 在 30 May 2013 编辑

Contents

适用版本

Series 60 3rd Edition



解决方案:


IMEI码全称International Mobile Equipment Identity,每台设备都拥有唯一的IMEI码,可以用于识别不同的移动设备。
下面的代码显示了在S60 3rd的设备上获取IMEI码:

IMEI_Getter.h

  1. include <e32base.h>
    #include <F32FILE.H>
    #include <d32dbms.h>
    #include <BADESCA.H>
    #include <Etel3rdParty.h>
    #include <MTCLREG.H>


    class MImeiObserver
    {
    public: // New methods
    virtual void GotIMEIL(const TDesC& aIMEI,TInt aError) = 0;
    };

    class CImeiReader : public CActive
    {

    public:
    static CImeiReader* NewL(MImeiObserver* aObserver);
    static CImeiReader* NewLC(MImeiObserver* aObserver);
    ~CImeiReader();
    protected:
    void DoCancel();
    void RunL();
    private:
    CImeiReader(MImeiObserver* aObserver);
    void ConstructL(void);
    private:
    MImeiObserver* iObserver;
    CTelephony* iTelephony;
    CTelephony::TPhoneIdV1 iIdV1;
    CTelephony::TPhoneIdV1Pckg iIdV1Pkg;
    };


IMEI_Getter.cpp

  1. include <COEMAIN.H>
    #include <BAUTILS.H>
    #include <apmrec.h>
    #include <apgcli.h>
    #include <smut.h>

    CImeiReader* CImeiReader::NewL(MImeiObserver* aObserver)
    {
    CImeiReader* self = NewLC(aObserver);
    CleanupStack::Pop(self);
    return self;
    }

    CImeiReader* CImeiReader::NewLC(MImeiObserver* aObserver)
    {
    CImeiReader* self = new (ELeave) CImeiReader(aObserver);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }


    CImeiReader::CImeiReader(MImeiObserver* aObserver)
    :CActive(0),iObserver(aObserver),iIdV1Pkg(iIdV1)
    {
    }

    CImeiReader::~CImeiReader()
    {
    Cancel();
    delete iTelephony;
    }


    void CImeiReader::ConstructL(void)
    {
    CActiveScheduler::Add(this);

    iTelephony = CTelephony::NewL();
    iTelephony->GetPhoneId(iStatus,iIdV1Pkg);
    SetActive();
    }

    void CImeiReader::DoCancel()
    {
    iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
    }

    void CImeiReader::RunL()
    {
    iObserver->GotIMEIL(iIdV1.iSerialNumber,iStatus.Int());
    }
This page was last modified on 30 May 2013, at 04:41.
36 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×