内容供学习使用,不得转卖,代码复制后请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;
}