<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Platform SDK</title>
        <link>http://geekswithblogs.net/suniljagadish/category/3444.aspx</link>
        <description>Platform SDK</description>
        <language>en-US</language>
        <copyright>Sunil Jagadish</copyright>
        <managingEditor>suniljagadish@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Power Management API in Platform SDK</title>
            <link>http://geekswithblogs.net/suniljagadish/archive/2005/11/30/61655.aspx</link>
            <description>&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;I demonstrated the Power Management API of the Microsoft Platform SDK during the &lt;/FONT&gt;&lt;A href="http://suniljagadish.blogspot.com/2005/11/microsoft-app-launch.html"&gt;&lt;FONT face=Tahoma size=2&gt;launch&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma size=2&gt; of Microsoft's Academic Projects Program here in Bangalore.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn.microsoft.com/platformsdk/"&gt;&lt;FONT face=Tahoma size=2&gt;Microsoft Platform SDK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Tahoma size=2&gt; is a colelction of powerful APIs which you can play around with to do a bit of system-level programming. You could use the Microsoft VC++ compiler to compile your programs.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;The Power Management Demo I showed is pretty simple and straight-forward. The user is intimated through an alert when there is a change in power source. In a real-time scenario one could perform actions to change the execution state/processor consmption of the application when the computer is running on battery. This is done using one simple function:&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;&lt;STRONG&gt;BOOL&lt;/STRONG&gt; &lt;B&gt;GetSystemPowerStatus(&lt;/B&gt;&lt;BR&gt;&amp;nbsp; &lt;B&gt;LPSYSTEM_POWER_STATUS&lt;/B&gt; &lt;I&gt;&lt;A class=synParam onclick=showTip(this) href=""&gt;lpSystemPowerStatus&lt;/A&gt;&lt;/I&gt;&lt;B&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;B&gt;&lt;BR&gt;&lt;/B&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#000000 size=2&gt;&lt;B&gt;);&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;to which you would have to pass the reference of an object of type SYSTEM_POWER_STATUS structure. The power source is indicated by the value of the structure variable&amp;nbsp;&lt;STRONG&gt;ACLineStatus&lt;/STRONG&gt;&amp;nbsp;(0 - Battery, 1 - AC Power &amp;amp; 255 - Unknown).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;In the main window message processing&amp;nbsp;function (WndProc), you can invoke this function when the&lt;/FONT&gt; &lt;FONT face="Courier New" size=2&gt;WM_POWERBROADCAST&lt;/FONT&gt; &lt;FONT face=Tahoma size=2&gt;message is received.&lt;/FONT&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;case&lt;/FONT&gt; WM_POWERBROADCAST:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;BOOL ret;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;SYSTEM_POWER_STATUS sps;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;ret = GetSystemPowerStatus(&amp;amp;sps);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;&lt;FONT color=#0000ff&gt;if&lt;/FONT&gt;(sps.ACLineStatus)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size=2&gt;MessageBox(hWnd,TEXT(&lt;FONT color=#800000&gt;"You are on AC power"&lt;/FONT&gt;),TEXT(&lt;FONT color=#800000&gt;"Power Management Demo"&lt;/FONT&gt;),0);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face="Courier New" size=2&gt;else&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT face="Courier New"&gt;MessageBox(hWnd,TEXT(&lt;FONT color=#800000&gt;"You are on battery power"&lt;/FONT&gt;),TEXT(&lt;FONT color=#800000&gt;"Power Management Demo"&lt;/FONT&gt;),0);&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Tahoma size=2&gt;By responding to the &lt;FONT face="Courier New"&gt;PBT_APMQUERYSUSPEND&lt;/FONT&gt; message, an application can put off&amp;nbsp;a suspend request from the operating system. The application will need to respond with a &lt;FONT face="Courier New"&gt;BROADCAST_QUERY_DENY&lt;/FONT&gt;, if the application cannot allow the system operations to be suspended. The Power Management API has other useful features to support automatic wake-up using the System Wake-up Events.&lt;BR&gt;&lt;BR&gt;[&lt;A href="http://www28.websamba.com/bdotnetstudent/PowerMgmtDemo.zip"&gt;Download Source&lt;/A&gt;]&lt;BR&gt;&lt;BR&gt;&lt;A href="http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/"&gt;Read&lt;/A&gt; about using Microsoft Visual C++ 2005 Express with Platform SDK.&lt;/FONT&gt;&lt;/P&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=61655"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=61655" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/suniljagadish/aggbug/61655.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Sunil Jagadish</dc:creator>
            <guid>http://geekswithblogs.net/suniljagadish/archive/2005/11/30/61655.aspx</guid>
            <pubDate>Wed, 30 Nov 2005 15:34:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/suniljagadish/comments/61655.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/suniljagadish/archive/2005/11/30/61655.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/suniljagadish/comments/commentRss/61655.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/suniljagadish/services/trackbacks/61655.aspx</trackback:ping>
        </item>
    </channel>
</rss>