Hello Folks,
I am back with yet another WinCE / Windows Mobile Solution this time it is something exciting and it is on Power Batter Suspend timeout related stuff. It is really challenging task to optimize battery life of any embedded device. Sometimes we want to control back light and battery suspend related activities through our program.
OK .. here is simple question how do you control Back light, suspend timeout .. etc event through program ? To answer this question one has to understand "How WinCE operates w.r.t Power driver and what exactly happens behind the scenes".
To simplify things ... i am going to divide whole things in three parts
1. WinCE OS Part whihc include Power / Battery drivers.
2. Application
3. Registry
Registry: It is the place where all values gets stored i.e it acts as media for storing and retrieving values. I hope it is clear that Registry is nothing but global storage media and it has NO power to trigger anything. So that means it is of new use if we simply change values at registry and we need to do something extra to inform Drivers to read new values from registry.
Application: It could be system application like Control Panel Backlight / Power OR your own application. Essentially it is the place where you want to trigger power related event to let Driver / OS know that there are new values available in the registry.
WinCE OS / Power Driver: Main piece of component responsible for reading values from registry and act accordingly. The way many Microsoft drivers work is that they read settings from the registry when they start. So changing the values in the registry will NOT make those changes take effect until the driver reloads them. Warm booting will do that, but that is an understandably undesirable requirement.
So how to get past this situation where one want to change these backlight / Battery power values take effect when application running? To answer this, we need to understand how Windows Mobile / WinCE control panel application works i.e In settings -> control panel we have application like backlight and power. If you observer them closely if you change values at respective application changes are immediate and we don't require to do warm reboot or soft reset. So, we need to use similar API which are used by these control panel applications.
OK OK ... enough of theory .. let me jump into code snippets and APIs.
When the Microsoft control panel applet is run, it reads the values from the registry and writes the changes back to the registry. It then signals the driver to re-load those values from the registry through the use of a pre-defined (but poorly documented) named event.
The event name for the inactivity timeouts is "PowerManager/ReloadActivityTimeouts". If this named event is created using CreatEvent() and then signalled using SetEvent(), the SysPwr driver will reload the activity timeouts from the registry. This is what the Microsoft control panel applet does when the timeout values are changed.
Here is code snippet ... please remember that following code snippet only for Battery power timeouts and its corresponding event name is , "PowerManager/ReloadActivityTimeouts". If you want to change backlight settings you need to use event called "BackLightChangeEvent".
void PowerSet()
{
WCHAR wszPowerValue[5] = L"\0";
INT nPowerValue;
DWORD dwValueChecked ;
HKEY hKey;
BYTE* byteData;
HRESULT hRes;
HANDLE hEvent;
BOOL bResult;
DWORD dwDisp;
WCHAR wszImageVersion[MAX_PATH] = L"\0";
dwValueChecked = 120 ; // Hard coded value to 120 sec .. battery timeout
hRes = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Power\\Timeouts", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp);
if ( hRes == ERROR_SUCCESS ) {
RegSetValueExW(hKey,L"BattSuspendTimeout",0,REG_DWORD,(LPBYTE)&dwValueChecked,sizeof(DWORD));
}
RegCloseKey(hKey);
WCHAR wszEvent[] = L"PowerManager/ReloadActivityTimeouts";
// WCHAR wszEvent[] = _T("BackLightChangeEvent"); // In case of backlight
// For backlight reg key is @ HKEY_CURRENT_USER\ControlPanel\Backlight
hEvent = CreateEventW( NULL, FALSE, TRUE, wszEvent );
if (hEvent != NULL ) {
if (SetEvent( hEvent )) {
wsprintf(wszImageVersion,L"SUCCESS: Value set to %d secs",dwValueChecked);
MessageBox( wszImageVersion , L"Event Set");
}
}
CloseHandle( hEvent );
PostMessageW( WM_SETTINGCHANGE, 0, 0);
}
Please let me know if you need any help w.r.t this article. Have good one !!!!!!!!!!!
I am back with yet another WinCE / Windows Mobile Solution this time it is something exciting and it is on Power Batter Suspend timeout related stuff. It is really challenging task to optimize battery life of any embedded device. Sometimes we want to control back light and battery suspend related activities through our program.
OK .. here is simple question how do you control Back light, suspend timeout .. etc event through program ? To answer this question one has to understand "How WinCE operates w.r.t Power driver and what exactly happens behind the scenes".
To simplify things ... i am going to divide whole things in three parts
1. WinCE OS Part whihc include Power / Battery drivers.
2. Application
3. Registry
Registry: It is the place where all values gets stored i.e it acts as media for storing and retrieving values. I hope it is clear that Registry is nothing but global storage media and it has NO power to trigger anything. So that means it is of new use if we simply change values at registry and we need to do something extra to inform Drivers to read new values from registry.
Application: It could be system application like Control Panel Backlight / Power OR your own application. Essentially it is the place where you want to trigger power related event to let Driver / OS know that there are new values available in the registry.
WinCE OS / Power Driver: Main piece of component responsible for reading values from registry and act accordingly. The way many Microsoft drivers work is that they read settings from the registry when they start. So changing the values in the registry will NOT make those changes take effect until the driver reloads them. Warm booting will do that, but that is an understandably undesirable requirement.
So how to get past this situation where one want to change these backlight / Battery power values take effect when application running? To answer this, we need to understand how Windows Mobile / WinCE control panel application works i.e In settings -> control panel we have application like backlight and power. If you observer them closely if you change values at respective application changes are immediate and we don't require to do warm reboot or soft reset. So, we need to use similar API which are used by these control panel applications.
OK OK ... enough of theory .. let me jump into code snippets and APIs.
When the Microsoft control panel applet is run, it reads the values from the registry and writes the changes back to the registry. It then signals the driver to re-load those values from the registry through the use of a pre-defined (but poorly documented) named event.
The event name for the inactivity timeouts is "PowerManager/ReloadActivityTimeouts". If this named event is created using CreatEvent() and then signalled using SetEvent(), the SysPwr driver will reload the activity timeouts from the registry. This is what the Microsoft control panel applet does when the timeout values are changed.
Here is code snippet ... please remember that following code snippet only for Battery power timeouts and its corresponding event name is , "PowerManager/ReloadActivityTimeouts". If you want to change backlight settings you need to use event called "BackLightChangeEvent".
void PowerSet()
{
WCHAR wszPowerValue[5] = L"\0";
INT nPowerValue;
DWORD dwValueChecked ;
HKEY hKey;
BYTE* byteData;
HRESULT hRes;
HANDLE hEvent;
BOOL bResult;
DWORD dwDisp;
WCHAR wszImageVersion[MAX_PATH] = L"\0";
dwValueChecked = 120 ; // Hard coded value to 120 sec .. battery timeout
hRes = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\Power\\Timeouts", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, &dwDisp);
if ( hRes == ERROR_SUCCESS ) {
RegSetValueExW(hKey,L"BattSuspendTimeout",0,REG_DWORD,(LPBYTE)&dwValueChecked,sizeof(DWORD));
}
RegCloseKey(hKey);
WCHAR wszEvent[] = L"PowerManager/ReloadActivityTimeouts";
// WCHAR wszEvent[] = _T("BackLightChangeEvent"); // In case of backlight
// For backlight reg key is @ HKEY_CURRENT_USER\ControlPanel\Backlight
hEvent = CreateEventW( NULL, FALSE, TRUE, wszEvent );
if (hEvent != NULL ) {
if (SetEvent( hEvent )) {
wsprintf(wszImageVersion,L"SUCCESS: Value set to %d secs",dwValueChecked);
MessageBox( wszImageVersion , L"Event Set");
}
}
CloseHandle( hEvent );
PostMessageW( WM_SETTINGCHANGE, 0, 0);
}
Please let me know if you need any help w.r.t this article. Have good one !!!!!!!!!!!
Comments
[http://www.webmonkey.com/tutorial/Christmas_card_with_photo/ christmas card with photo]
http://www.webmonkey.com/tutorial/Christmas_tree_store/
[http://www.testriffic.com/user/erttfkkmiodp/ looking for tamsulosin hcl inn bangladesh]
[http://www.webmonkey.com/tutorial/The_christmas/ the christmas]
http://www.webmonkey.com/tutorial/Buy_topamax_in_Vaughan/
http://www.webmonkey.com/tutorial/Christmas_present_boyfriend/
http://www.webmonkey.com/tutorial/Christina_aguilera_christmas_song/
keflex medicine
[url="http://www.webmonkey.com/tutorial/Christmas_tree_angel/"]christmas tree angel[/url]
[url="http://www.testriffic.com/user/Ira1328/"]celexa and testing methods[/url]
[url="http://www.testriffic.com/user/Clyde1202/"]barrets nexium[/url]
[url="http://www.webmonkey.com/tutorial/Buy_topamax_in_Vaughan/"]buy topamax in Vaughan [/url]
[url="http://www.webmonkey.com/tutorial/Christmas_card_photo_idea/"]christmas card photo idea[/url]
I suffer with recently bought a acquainted with laptop that is old. The person I had bought it from had installed windows xp on it, indeed though it originally came with windows Me. I want to expunge the windows xp because it runs slows on the laptop because it takes up more thought than the windows Me would. Also I want to unseat windows xp because it is an wrongful copy. So when I tried to hop to it updates on it, windows would not introduce updates because the windows xp is not genuine. [URL=http://coabusp.tripod.com]aden gillett[/URL]
----------------------------------------------------------------------
Answers :
It's more advisedly to relinquish [URL=http://mnepair.tripod.com/runtime-errors-with-ie8.html]runtime errors with ie8[/URL] Windows XP and good upgrade your laptop. It's much better. [URL=http://rgivrmi.tripod.com/australian-lunar-silver.html]australian lunar silver[/URL] In addition, Windows XP is way [URL=http://boixpau.tripod.com/choral-risers.html]choral risers[/URL] more advisedly then Windows Me. Windows Me is out and tons programs that can hustle with XP, can't [URL=http://epgotuo.tripod.com/vesting-in-equity-indexed-annuity.html]vesting in equity indexed annuity[/URL] run with Me.
------------------------------
all you have to do is insert the windows me disk into the cd drive. then reboot your laptop, when the black [URL=http://boixpau.tripod.com/chris-custer-baseball.html]chris custer baseball[/URL] sift with all the info comes up and when it asks u to boot from cd [URL=http://zbjwwcg.tripod.com/sacroiliac-pain-groin.html]sacroiliac pain groin[/URL] hit any clue when it tells you to then inaugurate from there !!! I RECOMEND SINCE ITS AN ILLEAGLE COPY TO WIPE [URL=http://qkapaaa.tripod.com/great-toe-joint-replacement.html]great toe joint replacement[/URL] ELSEWHERE THE [URL=http://ulvhvpw.tripod.com/snake-river-mls.html]snake river mls[/URL] ENTIRE TIRING PUSH WHEN IT ASKS YOU WHICH UNDENIABLE [URL=http://cosvsuo.tripod.com/isophorone-diamine.html]isophorone diamine[/URL] PROD TO POSITION IT ON. THEN SUM UP ALL THE UNUSED SPELL ON THE EMPTY [URL=http://iwpukge.tripod.com/steven-ravnitzky.html]steven ravnitzky[/URL] REALISTIC CONSTRAIN ONTO A UP TO DATE DOCUMENTATION SITE, IT INCLINATION LOOK LIKE C:/ Open or something like that
you can also check our untrained [url=http://freecasinogames2010.webs.com]casino[/url] orientate at http://freecasinogames2010.webs.com and thrive in discipline folding shin-plasters !
another exhibitionist [url=http://www.ttittancasino.com]casino spiele[/url] bite is www.ttittancasino.com , in lieu of of german gamblers, keep unstinting online casino bonus.
And according to this article, I totally agree with your opinion, but only this time! :)
the finest [url=http://de.casinoapart.com]casino[/url] against UK, german and all over the world. so in search the treatment of the cork [url=http://es.casinoapart.com]casino en linea[/url] corroborate us now.
Webmaster of http://loveepicentre.com and http://movieszone.eu
Best regards
unlock iphone 4
unlock iphone 4
http://www.extrasolar-planets.com/exoplanets/darwin.html http://www.salesandmarketing.com/article/dancing-jaws-dragon
My computer (xp) kept on showing this message about this csrss.exe thing....i have no experience with computers but i looked it up and it said that it's a system file or it cud be a virus??? i searched my computer for csrss.exe files and 3 results came up....i'll copy them onto this but can anybody tell me if any of these are viruses or not? please CSRSS.EXE-03323C54.pf location=C:\WINDOWS\Prefetch csrss.exe location=C:\WINDOWS\system32 csrss.exe location=C:\WINDOWS\ServicePackFiles\i38… P.S. i scanned them with AVG but it said that it has no infections...i don't know if i shud trust AVG I also scanned my whole computer with AVg and the sign about the csrss.exe doesn't come up anymore but i need to know if any of those files are viruses or not...thanks for the help :)
iphone 4 unlock how to unlock iphone 4
iphone 4 unlock [url=http://unlockiphone44.com]how to unlock iphone 4[/url] unlock iphone 4 unlock iphone 4
[/url]buy amitriptyline line
purchase endep 75 mg uk
purchase endep online australia
order amitriptyline 75 mg australia
buy amitriptyline 75 mg online
[/url] cymbalta migraine
duloxetine hydrochloride solubility
que es xeristar 60
dating lonely singles in the uk [url=http://loveepicentre.com/map.php]european dating pics[/url] free dating to relating ebook
sex dating bible passages [url=http://loveepicentre.com/]guitarist free dating[/url] christian dating for divoreced singles
age dating bone fractures [url=http://loveepicentre.com/articles.php]discreet adult dating sites[/url] predictable women in dating
speed dating in austin texas [url=http://loveepicentre.com/]dating vintage gucci purse[/url] dating advive for teenagers
n riel 50 dating [url=http://loveepicentre.com/]christian perspective common interests dating[/url] don't of dating
chad ocho cinco dating cheryl burke [url=http://loveepicentre.com/advice.php]peterborough ontario dating[/url] cops online dating
10043 track farmers personals dating [url=http://loveepicentre.com/map.php]gay dating melbourne[/url] 100 free online lesbian dating site
dating in hoffman estates [url=http://loveepicentre.com/success_stories.php]online dating service for rich people[/url] free dating sites in united state
online tall dating [url=http://loveepicentre.com/advice.php]divorce dating seattle[/url] dating daan
private dating [url=http://loveepicentre.com]elf dating[/url] dating free online plus service size
asian dallas dating [url=http://loveepicentre.com/]20 dating questions[/url] bbw sex dating sites
teen australia dating site [url=http://loveepicentre.com/]dating sites in the thames valley[/url] who is shawn white dating
local adutl sex and dating websites [url=http://loveepicentre.com/advice.php]how to beat dating games[/url] wives dating other men
dating site for fat guys [url=http://loveepicentre.com/success_stories.php]desperate wife dating[/url] new member chatter dating sites
dating legal seperation virginia [url=http://loveepicentre.com/]kenya dating women[/url] bbw singles dating mississippi
dating duluth [url=http://loveepicentre.com]alternative dating lesbian transsexual[/url] cool opening ines on dating sites
exclusive dating uk [url=http://loveepicentre.com/]christiian dating[/url] list of new gay dating sites
web dating scams [url=http://loveepicentre.com/advice.php]dominican dating[/url] dating in the u s 1990-2007
josh i kissed dating good bye [url=http://loveepicentre.com]when to announce you're dating[/url] dating the gospels
greek dating [url=http://loveepicentre.com/]free online adult dating sims[/url] horses and farm online dating
uk reality dating shows [url=http://loveepicentre.com/taketour.php]relative and absolute dating[/url] no subscription free dating sites
free houston dating [url=http://loveepicentre.com/]big dating sit sites 2008 dating[/url] dating in my 40s
friend jungle dating review [url=http://loveepicentre.com/advice.php]online dating chatting[/url] dating an emo girl
dating website no kids [url=http://loveepicentre.com/map.php]100 free no charge bbw dating[/url] who is jesse palmer dating
free dating for girls [url=http://loveepicentre.com/advice/]lynn southern california dating[/url] dating illinois watches
100 free european dating websites [url=http://loveepicentre.com]dating net works[/url] free mared dating sites [url=http://loveepicentre.com/user/kuzya/]kuzya[/url] speed dating tampa fl
max and erin dating [url=http://loveepicentre.com/advice/]speed dating couch street portland oregon[/url] polyamorous dating
columbus ohio dating sites [url=http://loveepicentre.com/articles/]speed dating in michigan[/url] tulsa casual dating [url=http://loveepicentre.com/user/ktom1138/]ktom1138[/url] peoples opinions on online dating
free online bbw dating [url=http://loveepicentre.com/]no upgrade free dating sites[/url] go phishing dating
personals free dating sites [url=http://loveepicentre.com]dangerous dating[/url] inmate dating [url=http://loveepicentre.com/user/sinisa32/]sinisa32[/url] international dating statistics
dating hot [url=http://loveepicentre.com/advice/]photos for dating websites[/url] dating services willams lake bc
dating sites classifieds [url=http://loveepicentre.com/faq/]senior dating website[/url] new dating [url=http://loveepicentre.com/user/toughtampafl/]toughtampafl[/url] dating monterey