|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionI use the Thinkpad laptop for my research work. Usually, I keep it working in the night for the simulation work. Therefore, when I wake up at the next morning, I can analyze the results immediately. I need to lock the WinXP system and turn off the monitor when I leave the laptop. Then I write this program to help me. It is more convenient to use than the traditional way (Win+L hotkey to lock the system and turn off monitor through power schemes). Code explanationThe code is very simple. First, turn off the monitor by using // Turn off monitor Sleep(500); // Eliminate user's interaction for 500 ms SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2); Second, use LockWorkStation(); Third, the #define _WIN32_WINNT 0x0500This program is very simple yet very useful. It keeps your task running on the laptop while turns off the monitor for saving energy and protects the laptop from unauthorized use.Reference
|
|||||||||||||||||||||||||||||||||||||||||||||||