Do you know that you can programmatically stop the user changing the date and time of a Pocket PC device?
This is useful if your applications need to take time accurately for some reason from the device.
The following code will disable the user from accessing the date time changing settings using his Windows Mobile powered device.
- private void btnDisableClock_Click(object sender, EventArgs e)
- {
- RegistryKey hklm = Registry.LocalMachine;
- hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);
- System.Byte[] offValue = new byte[1];
- offValue[0] = 0x30;
- hklm.SetValue("AppState", offValue);
- lblTitle.Text = "Change Clock Status - Disabled";
- }
If you want to re-enable the setting, to make the user able to change the data and time use the below code.
- private void btnEnableClock_Click(object sender, EventArgs e)
- {
- RegistryKey hklm = Registry.LocalMachine;
- hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);
- System.Byte[] offValue = new byte[1];
- offValue[0] = 0x11;
- hklm.SetValue("AppState", offValue);
- lblTitle.Text = "Change Clock Status - Enabled";
- }
No comments:
Post a Comment