Skip to content

Instantly share code, notes, and snippets.

@informationsea
Last active September 22, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save informationsea/582d0104b095290d749a83b8781d2741 to your computer and use it in GitHub Desktop.
Save informationsea/582d0104b095290d749a83b8781d2741 to your computer and use it in GitHub Desktop.
Lock windows and sleep display
#include <Windows.h>
int main()
{
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa376869(v=vs.85).aspx */
LockWorkStation();
/* https://msdn.microsoft.com/en-us/library/windows/desktop/ms644944(v=vs.85).aspx */
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment