Chris Tacke of OpenNetCF and I were talking about how to keep the backlight on in Windows CE 6.0 today. He had noticed that the function SystemIdleTimerReset() no longer kept the backlight on, but does keep the system running.   I had noticed this a while back, but didn’t have time to look into it. I did have a solution though.
The solution is to get an event name from the registry for an event that the power manager is monitoring. Then create the event and set it. Here is how I did it:
#define ACTIVITY_VALUE TEXT("ActivityEvent")
static HANDLE UserEvent = NULL;
HANDLE GetUserIdleEvent()
                TCHAR *EventName = NULL;
                DWORD Result;
                HKEY hKey;
                DWORD NumBytes = 0;
                DWORD Type;
                if( UserEvent == NULL)
                                // Open the Registry Key
                                Result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCWSTR)GWE_REG_PATH, 0, 0, &hKey);
                                if( ERROR_SUCCESS == Result )
                                                // This is a fake read, all it does is fill in NumBytes with the number of
                                                // bytes in the string value plus the null character.
                                                Result = RegQueryValueEx( hKey, ACTIVITY_VALUE, NULL, &Type, NULL, &NumBytes );
                                                if( NumBytes > 0 )
                                                                // Now we know how big the string is allocate and read it
                                                                EventName = (TCHAR *)malloc( NumBytes );
                                                                if( EventName != NULL )
                                                                                Result = RegQueryValueEx( hKey, ACTIVITY_VALUE, NULL, &Type, (LPBYTE)EventName, &NumBytes );
                                                RegCloseKey( hKey );
                                                UserEvent = CreateEvent( NULL, FALSE, FALSE, EventName );
                                                free( EventName );
                return UserEvent;
int UserIdleTimerReset()
                HANDLE hEvent = GetUserIdleEvent();
                if( hEvent != NULL)
                                SetEvent( hEvent );
                return TRUE;
Now just call UserIdleTimerReset() as needed to keep the backlight on.
Chris was kind enough to post a C# version of this on his blog at Chris Tacke - Preventing the backlight from turning off in CE 6.0.
Copyright © 2009 – Bruce Eitman
All Rights Reserved