Compartilhar via


Detecting ActiveSync State

4/8/2010

Applications can determine if a device is currently cradled and if synchronization is currently in progress by querying the following registry values that are maintained by the ActiveSync application.

HKLM\System\State\Hardware\Cradled

HKLM\System\State\ActiveSync\Synchronizing

Both of these are DWORD values. They are nonzero if the condition is true and zero if the condition is false.

Code Example

The following example shows how to determine whether a device is cradled or synchronizing.

BOOL IsCradled()
{
    DWORD dwCradled = 0;
    RegistryGetDWORD(HKEY_LOCAL_MACHINE, TEXT("System\\State\\Hardware"), TEXT("Cradled"), &dwCradled);
    return dwCradled;
}

BOOL IsSynchronizing()
{
    DWORD dwSynchronizing = 0;
    RegistryGetDWORD(HKEY_LOCAL_MACHINE, TEXT("System\\State\\ActiveSync"), TEXT("Synchronizing"), &dwSynchronizing);
    return dwSynchronizing;
}

These examples use the RegistryGetDWORD method to obtain the registry values. For more information on this and other methods for determining the current state of a device, see State and Notifications Broker.

See Also

Concepts

Handling Connection Notification

Other Resources

State and Notifications Broker