#include <windows.h>
#include <iostream>
int main()
{
int nScreenIndex = 0;
bool bIsLocked = false;
//获取系统指标,判断当前屏幕是否处于锁屏状态
if (GetSystemMetrics(nScreenIndex) == 1) {
bIsLocked = true;
std::cout << "the screen is locked!!" << std::endl;
}
if (bIsLocked) {
//计算机处于锁屏态
//执行锁屏状态下功能
/*******************/
/*******功能区******/
/*******************/
std::cout << "the screen is locked!!" << std::endl;
}
else {
//计算机处于非锁屏状态
std::cout << "the screen is unlocked!! to do lock!!" << std::endl;
//执行非锁屏状态下功能
/*******************/
/*******功能区******/
/*******************/
//锁屏
LockWorkStation();
}
return 0;
}