How to check whether the SIM card exists on Windows Mobile

Source: Internet
Author: 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

When SIM is on the device, the status value in HKEY_LOCAL_MACHINE // system // state // phone is 0x188000a0,

Bool gchecksimcardexist ()
{
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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.