Tuesday, February 13, 2007

Changes in password protection on Pocket PC 2002

Introduction

Password protection has changed in Pocket PC 2002. That is why some programs that used PromptForPasswd function may not work on Pocket PC 2002. This article describes new features and how you can make your program work on Pocket PC 2002.

Background

Using built-in password protection is a way to create an application that will run every time the device is switched on and no other applications can run until the application is finished. It is useful for creating two kinds of applications:

1. Different custom protection and security programs.
2. Applications for special devices based on Pocket PC. Applications that cannot be switched to other programs.

To create such a program one should create a custom DLL that exports PromptForPasswd function. This function should have the following signature: LPTSTR PromptForPasswd(HWND hParent);

This DLL should have .cpl extension. It is also needed to add Redirect value to the Password key in the Control Panel registry section:

HKEY_LOCAL_MACHINE\ControlPanel\Password\Redirect

After you create a DLL that exports PromptForPasswd function and register it in the registry in Redirect key your PromptForPasswd function will be called every time the device is switched on ... on Pocket PC but not on Pocket PC 2002.

New features of Pocket PC 2002

Pocket PC 2002 has two new password related features:

1. Alphanumeric password
2. Password activation delay ("Prompt if device unused for...")

The first feature is not interesting for us because Pocket PC also supports alphanumeric passwords. It is just a question of the default user interface. One can write a program for Pocket PC that will substitute the default password applet in the Control Panel with one that supports an alphanumeric password. For example you can download Microsoft Password for Pocket PC that replaces the standard Pocket PC 4 digit password applet with an alphanumeric one.

The second feature is a reason why some password related programs do not work on Pocket PC 2002. The password delay option ("Prompt if device unused for...") was added in oreder to simplify working with Pocket PC devices. If a delay is set to 30 minutes then password will not be asked (and PromptForPasswd function will not be called) for 30 minutes after the device is switched off. If you need your PromptForPasswd function to be called every time the device is switched on you should set the activation delay value to zero.

Setting password timeout

Password activation delay value is stored in registry in the following location: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Shell\ActivePeriod

You can set it to 0 if you want the old Pocket PC behavior.

Conclusion

Pocket PC 2002 is not backward compatible with Pocket PC. Password protection is a thing that changed. Programs that use PromptForPasswd function can work uproperly (sometimes PromptForPasswd function may not be called). However you can easily change your program to make it work on Pocket PC 2002 by changing ActivePeriod value in registry.

http://www.pocketpcdn.com/articles/pocketpc2002password.html