自定义设置一个屏保程序

用C语言写一个简单的窗口程序,目的是生成一个可视化的图形窗口,需要用到EasyX库,可在文章末尾的网盘链接中下载。该程序退出需左击鼠标,否则无法退出。

#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
#include<graphics.h>
#include<time.h>

int flag = 1;//标记
int w = GetSystemMetrics(SM_CXSCREEN); //屏幕宽
int h = GetSystemMetrics(SM_CYSCREEN); //屏幕高


void  Init()
{
	HWND hWnd = initgraph(w, h);//创建一个图形化窗口

	// 设置背景色为蓝色
	setbkcolor(BLUE);
	// 用背景色清空屏幕
	cleardevice();

	SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) - WS_CAPTION);//取消窗口边框

	// 设置窗口坐标,大小      
	SetWindowPos(hWnd,		//窗口句柄
		HWND_TOPMOST,		//是否要设置风格 //2.3 设置窗口不可移动,设置窗口不可被覆盖
		0, 0,				//坐标
		w, h,				//大小
		SWP_SHOWWINDOW);	//显示方式
}


void  evuw()
{
	settextstyle(45, 40, "黑体");//设置字体打下及格式
	//打印文字
	outtextxy(w / 2 - 100, h / 2 - 250, "蓝屏警告!!!");
	settextstyle(30, 25, "黑体");//设置字体打下及格式
	outtextxy(w / 2 - 350, h / 2 - 150, "你的电脑遇到不可修复的错误,即将关机");
	outtextxy(0, h / 2 - 100, "A problem has been detected and windos has been shut dows to ");
	outtextxy(0, h / 2 - 70, "prevent damage to your computer.");
	outtextxy(0, h / 2 - 30, "If this is the first time you've seen this stop error screen,");
	outtextxy(0, h / 2, "restart your computer.If this screen appears again,follow th-");
	outtextxy(0, h / 2 + 30, "ese steps;");
	outtextxy(0, h / 2 + 70, "Check to make sure any new hardare or software is properly in-");
	outtextxy(0, h / 2 + 100, "stalled.If this is a new installation,ask your hardware or s-");
	outtextxy(0, h / 2 + 130, "oftware manufacturer for any windows updates you might need;");
}


int  main()
{
	Init();
	evuw();
	while (flag)
	{
		if (MouseHit())
		{
			MOUSEMSG msg = GetMouseMsg();
			if (msg.uMsg == WM_LBUTTONDOWN)
			{
				flag = 0;
			}
		}
	}
	closegraph();//关闭窗口
	return  0;
}

将生成的可执行文件(.exe)文件后缀改为.scr,如图点击是即可。
在这里插入图片描述
此时文件的类型变为屏幕保护程序,将其复制到C:\Windows\SysWOW64下,此时会弹出需要管理员权限,点击继续即可。

接下来回到桌面,右击鼠标,选择个性化
在这里插入图片描述
选择锁屏界面,点击屏幕保护程序设置
在这里插入图片描述
在下拉框中找到刚刚复制的屏保程序,点击应用后即可,此时便设置成功。
在这里插入图片描述

EasyX链接:
链接:https://pan.baidu.com/s/1CTWMbqaATgx663M01vRA5A
提取码:2chn

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值