Detect Active Sync connection on WM 5 devices

Do you need a registry key to do a specific task? Would you like to customize the way your PocketPC/Smartphone looks and works? This is the right place.

Moderators: Teksoft, admin

Detect Active Sync connection on WM 5 devices

Postby Raul Tinca » Tue Jun 20, 2006 4:00 pm

On 2005 devices the RAS API doesn't help too much... but there is a key in the registry that is updated by the OS in case if an AS connection:

Registry key:
HKEY_LOCAL_MACHINE \ System\State\Hardware key:Cradled

Here is a short code to help you read this key programatically:

bool bisActiveSyncConnected()
{
HKEY hKey;
DWORD dwTip, dwPos;
DWORD dwsize = sizeof(DWORD);
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("System\\State\\Hardware"), 0, 0, &hKey) == ERROR_SUCCESS)
{
if (RegQueryValueEx(hKey, _T("Cradled"), 0, &dwTip, (LPBYTE)&dwPos, &dwsize)==ERROR_SUCCESS)
{
RegCloseKey(hKey);
return (dwPos>0);
}
else return 0;
}
return 0;
}

You can also register for notifications related to changes on this key value. ;)
Raul Tinca
TEK-Giant
TEK-Giant
 
Posts: 272
Joined: Thu Apr 06, 2006 11:04 am

Postby dr.ppc » Tue Jan 16, 2007 11:01 am

Hi,

What do you mean "You can also register for notifications related to changes on this key value. "

Could you please point me how to to that? You mean to automatically monitor the change of registry (key value)?

Thanks & best wishes,

dr.ppc
dr.ppc
TEK-Newbie
TEK-Newbie
 
Posts: 1
Joined: Tue Jan 16, 2007 10:54 am

Postby Raul Tinca » Tue Jan 16, 2007 4:28 pm

The following table shows the registry notification functions with a description of the purpose of each.

CeFindCloseRegChange This function stops change notification handle monitoring.
CeFindFirstRegChange This function creates a change notification handle and sets up initial change notification filter conditions. A wait on a notification handle succeeds when a change matching the filter conditions occurs in the specified registry key, or subkeys.
CeFindNextRegChange This function requests that the operating system signal a change notification handle the next time it detects an appropriate change.

Cheers,
Raul
Raul Tinca
TEK-Giant
TEK-Giant
 
Posts: 272
Joined: Thu Apr 06, 2006 11:04 am


Return to Developers

Who is online

Users browsing this forum: No registered users and 0 guests