蓝屏程序

· · 个人记录

#include <bits/stdc++.h>
using namespace std;
int main(){
    system("start powershell Start-Process PowerShell -Verb RunAs wininit");
    return 0;
}

加入定时程序,可以实现定时蓝屏(定时程序见代码):


#include <stdio.h>
#include <time.h>
#include <windows.h>
int t1,t2,t3,t4,t5,t6;
int main() {
    SetConsoleTitle("蓝屏");
    HWND hwnd = GetForegroundWindow();
    RECT windowRect;
    GetWindowRect(hwnd, &windowRect);
    int newWidth = 600;
    int newHeight = 150;
    int x = (windowRect.right + windowRect.left - newWidth) / 2;
    int y = (windowRect.bottom + windowRect.top - newHeight) / 2;
    SetWindowPos(hwnd, NULL, x, y, newWidth, newHeight, SWP_NOZORDER);
    SetWindowLongPtrA(GetConsoleWindow(), GWL_STYLE, GetWindowLongPtrA(GetConsoleWindow(),GWL_STYLE)& ~WS_SIZEBOX & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
//初始化
    printf("请输入蓝屏的时间(年月日时分秒):");
    scanf("%d%d%d%d%d%d",&t1,&t2,&t3,&t4,&t5,&t6);
    system("cls");
    while(1){
        time_t seconds = time(NULL); 
        struct tm *local_time = localtime(&seconds); 
        printf("当前时间: %d-%02d-%02d %02d:%02d:%02d\n",
            local_time->tm_year + 1900, 
            local_time->tm_mon + 1,    
            local_time->tm_mon + 1,       
            local_time->tm_hour,       
            local_time->tm_min,        
            local_time->tm_sec);
        printf("蓝屏时间:%d-%02d-%02d %02d:%02d:%02d\n",t1,t2,t3,t4,t5,t6);
        if(t1==local_time->tm_year + 1900&&t2==local_time->tm_mon + 1&&t3==local_time->tm_mday&&t4==local_time->tm_hour&&t5==local_time->tm_min){
            system("start powershell Start-Process PowerShell -Verb RunAs wininit");
            break;
        }
        Sleep(1000);
        system("cls");
    }    
    return 0;
}