<br>Hi, <br>The requirement is with respect to suspension and automatic resumption of the system.<br><br>For this WinAPI functions like<br><br>SetSystemPowerState()<br>GetSystemPowerStatus()<br>SYSTEM_POWER_STATUS<br><br>have been used.<br><br>EXTRACT FROM THE CODING:<br><br>LRESULT CALLBACK WndProc(HWND hWnd , UINT message ,WPARAM wParam ,LPARAM lParam)<br>{<br> static HCURSOR hCursor;<br> static int nXpos=0,nYpos=0;<br> <br> switch(message)<br> {<br><br> case WM_CREATE:<br> hCursor = LoadCursor(NULL,IDC_ARROW);<br> break;<br> <br> case WM_COMMAND:<br> switch(LOWORD(wParam))<br> {<br> <br> case ID_EXIT:<br><br> DestroyWindow(hWnd);<br> break;<br><br> case ID_QUERYSTATUS:<br> {<br> SetSystemPowerState(TRUE,FALSE);<br> wParam=PBT_APMRESUMESUSPEND;<br> }<br> break;<br> }<br> break;<br><br> case WM_POWERBROADCAST:<br><br> if(wParam == PBT_APMQUERYSUSPEND)<br> {<br> char szBuffer[100],szBuffer1[100];<br> HDC hdc = GetDC(hWnd);<br> <br> SYSTEM_POWER_STATUS ps;<br> GetSystemPowerStatus(&ps);<br> wsprintf(szBuffer,"AcLineStatus=%d,BatteryFlag=%d,BatteryFullLifeTime=%ld",<br> ps.ACLineStatus ,ps.BatteryFlag ,ps.BatteryFullLifeTime );<br> wsprintf(szBuffer1,"BatteryLifePercent=%d,BatteryLifetime=%ld,Reserved1=%d",<br> ps.BatteryLifePercent ,ps.BatteryLifeTime ,ps.Reserved1 );<br> <br> TextOut(hdc,0,0,szBuffer,lstrlen(szBuffer));<br> TextOut(hdc,50,50,szBuffer1,lstrlen(szBuffer1));<br><br> if(ps.ACLineStatus )<br> {<br> <br> int Reply = MessageBox(hWnd,"Do you want to suspend(Y/N)?","Suspension state",MB_YESNO);<br> <br> if(Reply == IDYES)<br> return TRUE;<br> else<br> return FALSE;<br> <br> }<br> }<br> return (DefWindowProc(hWnd,message,wParam,lParam));<br><br> case WM_DESTROY:<br><br> PostQuitMessage(0);<br> break;<br> <br> default:<br> return DefWindowProc(hWnd,message,wParam,lParam);<br>}<br> return(0L);<br>}<br><br>/////////////////////////////////////////////////////////////////////////////////////////////////<br><br>The problems encountered are:<br><br>1. Suspension and automatic resumption occurs, but not at all times, in the sense after suspension the systems waits in the suspended state until the key is pressed manually by the user to bring it to the resumption state.(Win 95)<br> What could be the reason for this?<br><br>2. The same program when run on laptop gets into suspension state and automatic resumption is not taking place at all when compared with Win 95(point No:1) as told above.<br><br><br>Could anyone suggest a solution for this problem?