Get Windows system lock and unlock computer events

Source: Internet
Author: User

During development, you may encounter a lock or unlock event for obtaining the computer.ProgramWhat to do and what the program will do after unlocking. For example, after locking the unlocked 3D device component, the lost becomes invalid and needs to be retrieved again. Otherwise, the 3D device will not be refreshed.

 

So what should we do?

 

Registersessionnotification and unregistersessionnotification can be used for registration and anti-registration. To obtain notification events, wm_wtssession_change messages will be sent to the registration window when an event exists. The corresponding wparam parameter can be parsed as follows:

// Wparam values:
Wts_lele_connect = 1;
Wts_lele_disconnect = 2;
Wts_remote_connect = 3;
Wts_remote_disconnect = 4;
Wts_session_logon = 5;
Wts_session_logoff = 6;
Wts_session_lock = 7;
Wts_session_unlock = 8;
Wts_session_remote_control = 9;

 

In addition to the above methods, you can use a global hook to intercept lockworkstation in user32.dll to obtain it. Or rewrite the DLL corresponding to Winlogon. However, it is still simple and secure.

 

For the following two methods, see:

Http://topic.csdn.net/u/20070516/09/132db03e-d0d8-4a92-9862-8a1e1e41b224.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.