windows mobile檢查SIM卡是否存在的方法

來源:互聯網
上載者:User

// PhoneNoSim
// Gets a value indicating whether the Subscriber Identity Module (SIM) is installed in the mobile device.
#define SN_PHONENOSIM_ROOT HKEY_LOCAL_MACHINE
#define SN_PHONENOSIM_PATH TEXT("System//State//Phone")
#define SN_PHONENOSIM_VALUE TEXT("Status")
#define SN_PHONENOSIM_BITMASK 2

 
////////////////////////////////////////////////////////////////////////////////
// PhoneInvalidSim
// Gets a value indicating whether the Subscriber Identity Module (SIM) is invalid.
#define SN_PHONEINVALIDSIM_ROOT HKEY_LOCAL_MACHINE
#define SN_PHONEINVALIDSIM_PATH TEXT("System//State//Phone")
#define SN_PHONEINVALIDSIM_VALUE TEXT("Status")
#define SN_PHONEINVALIDSIM_BITMASK 4

 
////////////////////////////////////////////////////////////////////////////////
// PhoneBlockedSim
// Gets a value indicating whether the Subscriber Identity Module (SIM) is blocked.
#define SN_PHONEBLOCKEDSIM_ROOT HKEY_LOCAL_MACHINE
#define SN_PHONEBLOCKEDSIM_PATH TEXT("System//State//Phone")
#define SN_PHONEBLOCKEDSIM_VALUE TEXT("Status")
#define SN_PHONEBLOCKEDSIM_BITMASK 8

裝置上有sim時,HKEY_LOCAL_MACHINE//System//State//Phone中的Status值0x188000a0,

BOOL GCheckSIMCardExist()
{
    HKEY  hKey    = NULL;
    DWORD dwDisposition;
    DWORD dwType;
    DWORD cbData;
    BOOL fgResult = FALSE;

    if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("//System//State//Phone"),
        0, NULL, 0, 0, NULL,
        &hKey, &dwDisposition) != ERROR_SUCCESS)
    {
        ASSERT(0);
    }
    cbData = sizeof(DWORD);
    if (RegQueryValueEx(hKey, _T("Status"), 0, &dwType,
        (LPBYTE) &dwDisposition, &cbData) != ERROR_SUCCESS)
    {
        ASSERT(0);
    }
    RegCloseKey(hKey);

   // return value is  0x002000a2 when not exist sim.
    dwDisposition &= 0x2;
    if(dwDisposition == 0)
    {
        fgResult = TRUE;
    }
}

 

 

http://hailang19821213.blog.163.com/blog/static/306794612010315111847763/

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.