// 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/