windows 锁屏功能

#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;
}

  

posted @ 2023-09-15 14:48  冥天笑  阅读(116)  评论(0编辑  收藏  举报