Sunil Jagadish

Archive for November 2005

Web Services – Cool demo

leave a comment »

The other demo I showed during the launch of Microsoft Academic Projects was to demonstrate the web services. Though this demo may not have real business application, one will be able to guess the power of Web Services and its extensibility.

I setup my webcam at home and used TinCam, to dump images shot from the webcam into a folder at a given interval. I referred this article and used Binary Serialization to transmit the images from my PC to the Web Service consumer application which is a simple WinForms application.

A very simple application, but cool to watch. Download the source here.

Written by Sunil

2005.11.30 at 05:24 AM

Posted in .NET, Programming

Power Management API in Platform SDK

leave a comment »

I demonstrated the Power Management API of the Microsoft Platform SDK during the launch of Microsoft's Academic Projects Program here in Bangalore.

Microsoft Platform SDK 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.

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:

BOOL GetSystemPowerStatus(
  LPSYSTEM_POWER_STATUS lpSystemPowerStatus

);

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 ACLineStatus (0 – Battery, 1 – AC Power & 255 – Unknown).

In the main window message processing function (WndProc), you can invoke this function when the WM_POWERBROADCAST message is received.

case WM_POWERBROADCAST:

BOOL ret;

SYSTEM_POWER_STATUS sps;

ret = GetSystemPowerStatus(&sps);

if(sps.ACLineStatus)

MessageBox(hWnd,TEXT("You are on AC power"),TEXT("Power Management Demo"),0);

else

MessageBox(hWnd,TEXT("You are on battery power"),TEXT("Power Management Demo"),0);

By responding to the PBT_APMQUERYSUSPEND message, an application can put off a suspend request from the operating system. The application will need to respond with a BROADCAST_QUERY_DENY, 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.

[Download Source]

Read about using Microsoft Visual C++ 2005 Express with Platform SDK.

Written by Sunil

2005.11.30 at 05:21 AM

Posted in .NET, Programming