zoukankan      html  css  js  c++  java
  • 二版手机读取SIM通讯录

    TInt GetSimContactCountL()
        {
        TInt SimCntCount = 0;   
        /*this code is just to get the TSY name*/
        CCommsDatabase* db = CCommsDatabase::NewL(EDatabaseTypeUnspecified);     
        CleanupStack::PushL(db);     
        CCommsDbTableView* table = db->OpenTableLC(TPtrC(MODEM));     
        table->GotoFirstRecord();   
        table->ReadTextL(TPtrC(MODEM_TSY_NAME),iTsyName);   
        // Cleanup - CommsDB no longer needed 
        CleanupStack::PopAndDestroy(2); // table,db     
        // Connect to the ETel server 
        RTelServer aTelServer;     
        User::LeaveIfError(aTelServer.Connect());     
        CleanupClosePushL(aTelServer);     
        User::LeaveIfError(aTelServer.LoadPhoneModule(iTsyName));     
        TInt numberOfPhones;     
        User::LeaveIfError(aTelServer.EnumeratePhones(numberOfPhones));     
        SimCntCount = 0;   
        for (TInt i=numberOfPhones; i>0; i--) { 
        // Get the phone name 
        RTelServer::TPhoneInfo phoneInfo; 
        User::LeaveIfError(aTelServer.GetPhoneInfo(i-1,phoneInfo)); 
        // Open the phone by name 
        RBasicGsmPhone phone; 
        User::LeaveIfError(phone.Open(aTelServer,phoneInfo.iName)); 
        TInt phoneBookCount;
        phone.EnumeratePhoneBooks(phoneBookCount);
        RBasicGsmPhone::TPhoneBookInfo aPbInfo;
        for(TInt j=0;j<phoneBookCount;j++){
        phone.GetPhoneBookInfo(j,aPbInfo);
        SimCntCount += aPbInfo.iUsed;
        }
        phone.Close();
        } 
        CleanupStack::PopAndDestroy(1); 
        return SimCntCount;
        }

  • 相关阅读:
    阿里云“网红"运维工程师白金:做一个平凡的圆梦人
    3235 战争
    1291 火车线路(区间修改,区间最值)
    P3183 [HAOI2016]食物链
    P1189 SEARCH(逃跑的拉尔夫)
    P1794 装备运输_NOI导刊2010提高(04)
    P2347 砝码称重
    P1332 血色先锋队
    P1772 [ZJOI2006]物流运输
    P1038 神经网络
  • 原文地址:https://www.cnblogs.com/yaoliang11/p/1928915.html
Copyright © 2011-2022 走看看