Introduction
This article give you the tips on how to have a floating SIP control in your Pocket PC/Windows CE .NET device. At the same time, you have learn on how to do a soft reset (without pressing any button) on your device.
Background
You need to have some basic idea on how to access the registry as well as changing the respective value. The key value in this article is changing the registry value in order to create a floating SIP control.
Using the code
To implement this is quite simple, all you need is to include the soft reset API declare from winioctl.h as shown below, so that you can call the reset function right after changing the registry value.
#include <winioctl.h>
#define IOCTL_HAL_REBOOT CTL_CODE(FILE_DEVICE_HAL, 15,
METHOD_BUFFERED, FILE_ANY_ACCESS)
extern "C" __declspec(dllimport) BOOL KernelIoControl(
DWORD dwIoControlCode,
LPVOID lpInBuf,
DWORD nInBufSize,
LPVOID lpOutBuf,
DWORD nOutBufSize,
LPDWORD lpBytesReturned);
Once you have declared the above API, then you are free to execute the declare function as the code show below:
KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);
Next is the registry location for SIP style where the OS reference to. This will be the key value before the OS proceeds to create the SIP control. Therefore, the SIP style is controlled by the following registry key:
HKEY_CURRENT_USER\ControlPanel\Sip\DragStyle
DragStyle
= 0, means the SIP is non-movable.
DragStyle
= 1, means the SIP is movable.
I have simplified the registry access by putting all the messy code into the few functions defined under the RegEdit.h and RegEdit.cpp. Hence, all you need is to call the SaveDWORD
with the correct value when you tend to switch from non-movable to movable SIP control or vice-versa.
SaveDWORD(HKEY_CURRENT_USER, TEXT("ControlPanel\\Sip"),
TEXT("DragStyle"), 1);
SaveDWORD(HKEY_CURRENT_USER, TEXT("ControlPanel\\Sip"),
TEXT("DragStyle"), 0);
A soft reset is required for the changes made to take effect. Hence, after the above code is executed, the device is going to reset with the discuss reset function.
Points of interest
Feel free to explorer more on the Pocket PC registry setting and you will get more fun with it.