我厌倦了做一个让Graphics“毛刺”的搞笑病毒。(注意:此代码是用C++编写的。)以下是代码:
#include <windows.h>
int main(){
HDC hdc = GetDC(HWND_DESKTOP);
POINT wPt[3];
RECT wRect;
int x = GetSystemMetrics(0), y = GetSystemMetrics(1);
while (TRUE)
{
int c = 10
;GetWindowRect(GetDesktopWindow(), &wRect);
WPT[0].x = wRect.left + rand() % 21 - 11;
WPt[0].x = wRect.bottom + rand() % 21 - 11;
WPt[0].x = wRect.right + rand() % 21 - 11;
WPt[0].x = wRect.top + rand() % 10 - 5;
WPt[0].x = wRect.left + rand() % c;
WPt[0].x = wRect.bottom + rand() % 5 - c;
PlgBlt(hdc, wPt, hdc, wRect.left, wRect.bottom - wRect.right, wRect.left, wRect.bottom - wRect.top, 0, 0, 0,);
Sleep(300);
}
}
发布于 2021-09-03 22:07:47
因为你在复制/粘贴的时候没有注意到细节。
还有许多其他错误: WPt、wPt、WPT的名称不同,调用PlgBlt的末尾有过多的逗号,等等。
祝你玩得开心:
#include <windows.h>
int main() {
HDC hdc = GetDC(HWND_DESKTOP);
POINT WPT[3];
RECT wRect;
int x = GetSystemMetrics(0), y = GetSystemMetrics(1);
while (TRUE)
{
int c = 10
;GetWindowRect(GetDesktopWindow(), &wRect);
WPT[0].x = wRect.left + rand() % 21 - 11;
WPT[0].y = wRect.bottom + rand() % 21 - 11;
WPT[1].x = wRect.right + rand() % 21 - 11;
WPT[1].y = wRect.top + rand() % 10 - 5;
WPT[2].x = wRect.left + rand() % c;
WPT[2].y = wRect.bottom + rand() % 5 - c;
PlgBlt(hdc, WPT, hdc, wRect.left, wRect.bottom - wRect.right, wRect.left, wRect.bottom - wRect.top, 0, 0, 0);
Sleep(300);
}
}
停止制造病毒,即使是开个玩笑。从一开始就做一些有用的事情。
https://stackoverflow.com/questions/69028205
复制相似问题