自定义设置一个屏保程序
生活随笔
收集整理的這篇文章主要介紹了
自定义设置一个屏保程序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用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
總結
以上是生活随笔為你收集整理的自定义设置一个屏保程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux debian ubuntu的
- 下一篇: C++总结篇(3)String类