仿照MEMZ做一个特效程序

2021/11/27 14:10:07

本文主要是介绍仿照MEMZ做一个特效程序,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

此程序基于MFC,核心代码配有注释

// 特效程序1Dlg.cpp : 实现文件
//

#include "stdafx.h"
#include "特效程序1.h"
#include "特效程序1Dlg.h"
#include "afxdialogex.h"
#include <Windows.h>
#include<Mmsystem.h>
#include <MMSystem.h>
#pragma comment (lib,"Winmm")
#pragma comment(lib,"winmm.lib")
#include   <dwmapi.h>
#pragma comment (lib , "dwmapi.lib" )
#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// C特效程序1Dlg 对话框



C特效程序1Dlg::C特效程序1Dlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_MY1_DIALOG, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void C特效程序1Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(C特效程序1Dlg, CDialogEx)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_MFCBUTTON1, &C特效程序1Dlg::OnBnClickedMfcbutton1)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_MFCBUTTON2, &C特效程序1Dlg::OnBnClickedMfcbutton2)
	ON_WM_ERASEBKGND()
	ON_WM_CLOSE()
END_MESSAGE_MAP()


// C特效程序1Dlg 消息处理程序

BOOL C特效程序1Dlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 设置此对话框的图标。  当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标
	

	char UserName[100];
	unsigned long nSize = 100;
	CString temp;
	GetUserName(UserName, &nSize);
	temp = UserName;
	temp += ",你好";
	GetDlgItem(IDC_STATIC1)->SetWindowTextA(temp);
	char UserName1[100];
	unsigned long nSize1 = 100;
	CString temp1;
	GetComputerName(UserName1, &nSize1);
	temp1 = UserName1;
	temp1 += "电脑,你好";
	GetDlgItem(IDC_STATIC2)->SetWindowTextA(temp1);
	char hostname[128];
	//gethostname(hostname, 128);//获得主机名  
	DWORD ser;
	char filename[128];
	::GetVolumeInformation("c:\\", hostname, 128, &ser, 0, 0, filename, 128);
	CString DiskID;
	DiskID.Format("%08X", ser);
	CString temp2,temp3;
	temp2 += "磁盘序列号:";
	temp2 += DiskID;
	temp2 += "C盘,你好";
	GetDlgItem(IDC_STATIC3)->SetWindowTextA(temp2);
	temp3 = filename;
	temp3 += "文件系统,你好";
	GetDlgItem(IDC_STATIC4)->SetWindowTextA(temp3);

	

	// TODO: 在此添加额外的初始化代码
	
	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}

// 如果向对话框添加最小化按钮,则需要下面的代码
//  来绘制该图标。  对于使用文档/视图模型的 MFC 应用程序,
//  这将由框架自动完成。

void C特效程序1Dlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 用于绘制的设备上下文

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// 使图标在工作区矩形中居中
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// 绘制图标
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialogEx::OnPaint();
	}
}

//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR C特效程序1Dlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

POINT pt;
BOOL exitc = 0;
CDC *pDcc;
DWORD WINAPI ThreadProc(LPVOID a) {
	POINT point1;
	int i = 0, k = 1;
	while (1>0)//死循环 
	{
		for (i = 0; i < 1000; i++)
		{
			if (exitc) {
				GetCursorPos(&point1);
				SetCursorPos(point1.x + rand() % k - rand() % k,
				point1.y + rand() % k - rand() % k);//鼠标移到屏幕的指定位置
				//部分代码鸣谢哔哩哔哩红烧稽
				Sleep(10);
			}
			else {
				return 0;
			}
		}
		if (k < 50)
		{
			Sleep(10);
			k++;
		}
	}
	return 0;
}
void C特效程序1Dlg::OnBnClickedMfcbutton1()
{
	GetDlgItem(IDC_MFCBUTTON1)->EnableWindow(FALSE);
	GetDlgItem(IDC_MFCBUTTON2)->EnableWindow(TRUE);
	CFile file("无标题.txt",CFile::modeCreate|CFile::modeWrite);//打开文件
	file.Write("YOUR COMPUTER HAS BEEN FUCKED BY THE MEMZ TROJAN.\r\nYour computer won't boot up again,\r\nso use it as long as you can!\r\n:D\r\nTrying to kill MEMZ will cause your system to\r\nbedestroyed instantly, so don t try it\r\n :D",strlen("YOUR COMPUTER HAS BEEN FUCKED BY THE MEMZ TROJAN.\r\nYour computer won't boot up again,\r\nso use it as long as you can!\r\n:D\r\nTrying to kill MEMZ will cause your system to\r\nbedestroyed instantly, so don t try it\r\n :D"));//写入文件
	file.Close();//关闭文件句柄
	ShellExecute(NULL,"open","无标题.txt",NULL,NULL,SW_SHOW);//以文件关联打开
	HWND hwnd = ::GetDesktopWindow();  //获取桌面句柄
	HDC hdc = ::GetWindowDC(hwnd); //获取桌面上下文的句柄
	BitBlt(hdc, 0, 0, GetSystemMetrics(SM_CXSCREEN),/*获取屏幕宽度*/GetSystemMetrics(SM_CYSCREEN), hdc, 0, 0, DSTINVERT);
	GetCursorPos(&pt);//获取鼠标位置
	//DrawIcon(::GetDC(0), pt.x, pt.y, LoadIcon(0, IDI_WARNING));
	DrawIcon(::GetDC(0), pt.x, pt.y, LoadIcon(0, IDI_ERROR));//绘制图标
	PlaySound(MAKEINTRESOURCE(IDR_WAVE1), AfxGetResourceHandle(), SND_ASYNC | SND_RESOURCE | SND_NODEFAULT | SND_LOOP);//播放声音
	SetTimer(1, 500,NULL);//此处均为设定计时器
	SetTimer(2, 200, NULL);
	SetTimer(3, 10000, NULL);
	SetTimer(4, 50, NULL);
	SetTimer(5, 7000, NULL);
	SetTimer(6, 6000, NULL);
	SetTimer(7, 700, NULL);
	SetTimer(8, 5000, NULL);
	SwapMouseButton(TRUE);
	CreateThread(NULL, NULL, ThreadProc, NULL, 0, NULL);
	exitc = 1;
	
	// TODO: 在此添加控件通知处理程序代码
}


void C特效程序1Dlg::OnTimer(UINT_PTR nIDEvent)//计时器消息的处理程序
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	if (nIDEvent == 1) {
		HWND hwnd = ::GetDesktopWindow();  //获取桌面句柄
		HDC hdc = ::GetWindowDC(hwnd); //获取桌面上下文的句柄
		BitBlt(hdc, 0, 0, GetSystemMetrics(SM_CXSCREEN),/*获取屏幕宽度*/GetSystemMetrics(SM_CYSCREEN), hdc, 0, 0, DSTINVERT);//反色
		HWND hwnd10 = ::GetDesktopWindow();  //获取桌面句柄
		HDC hdc10 = ::GetWindowDC(hwnd10); //获取桌面上下文的句柄
		StretchBlt(hdc10, 0,
			GetSystemMetrics(SM_CYSCREEN),/*获取屏幕宽度*/
			GetSystemMetrics(SM_CXSCREEN),/*获取屏幕高度*/
			-GetSystemMetrics(SM_CYSCREEN),/*颠倒的屏幕*/
			hdc10, 0, 0,
			GetSystemMetrics(SM_CXSCREEN), /*获取屏幕宽度*/
			GetSystemMetrics(SM_CYSCREEN), /*获取屏幕高度*/
			SRCAND/*通过使用AND(与)操作符来将源和目标矩形区域内的颜色合并。*/);
		
}
	//POINT pt;
	else {
		if (nIDEvent == 2)
		{
			GetCursorPos(&pt);//获得鼠标位置
			//DrawIcon(::GetDC(0), pt.x, pt.y, LoadIcon(0, IDI_WARNING));
			DrawIcon(::GetDC(0)/*获取DC*/, pt.x, pt.y, LoadIcon(0, IDI_ERROR));//绘制图标
		}
		else {
			if (nIDEvent == 3)
			{
				ShellExecute(0, NULL, "http://www.google.com/", NULL, NULL, SW_SHOW/*NORMAL*/);//打开一个无法访问的网页
			}
			else {
				/*CBitmap bitmap;
				bitmap.LoadBitmapA(IDB_BITMAP1);*/
				//CDC dc;
				/*HWND hwnd = ::GetDesktopWindow();  //获取桌面句柄
				HDC hdc = ::GetWindowDC(hwnd); //获取桌面上下文的句柄
				BitBlt(hdc, 0, 0,GetSystemMetrics(SM_CXSCREEN),/*获取屏幕宽度*\/*//*GetSystemMetrics(SM_CYSCREEN),/*获取屏幕高度*\/hdc, 0, 0, SRCCOPY);*/
				//Sleep(500);   //等待500毫秒(也就是0.5秒)
				//

				//dc.CreateCompatibleDC(pDcc);
				//dc.SelectObject(&bitmap);
				//CRect rect;
				//GetClientRect(&rect);
				//pDcc->BitBlt(0, 0, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
				/*CPoint pos1;
				pos1.x = 0;
				pos1.y = 5000;
				CBrush brush(RGB(255, 0, 0));
				CClientDC dc(this);
				//CWindowDC dc(GetDesktopWindow());
				dc.FillRect(dc.CRect(pos1.x,pos1.y), &brush);*/
				//YOUR COMPUTER HaS BEEH FUCKED BY THE MEM2 TROJAN.
//Your conputer uon't boot up again,\ns0 use it as 1ong as you cant\n	: D\n	Irying to kill HENR ui11 cause your systen to be\n	destroyed instantly, s0 don't try it :D
				if (nIDEvent == 4) {
					HWND hWnd1 = ::FindWindow(NULL, "任务管理器");
					HWND hWnd2 = ::FindWindow(NULL, "Windows 任务管理器");//获取任务管理器窗口句柄
					//MessageBox("正在获得窗口句柄");
					//if (hWnd != NULL)
					//{
					::PostMessage(hWnd1, WM_DESTROY, NULL, NULL);
					//}
					//if (hWnd1 != NULL) {
					::PostMessage(hWnd2, WM_DESTROY, NULL, NULL);//向任务管理器发送关闭消息
				}
				else {
					if (nIDEvent == 5) {
						HWND hwnd3 = ::GetDesktopWindow();  //获取桌面句柄
						HDC hdc1 = ::GetWindowDC(hwnd3); //获取桌面上下文的句柄
						BitBlt(hdc1, 0, 0, GetSystemMetrics(SM_CXSCREEN),/*获取屏幕宽度*/GetSystemMetrics(SM_CYSCREEN), hdc1, 0, 0, BLACKNESS);
						//Sleep(1000);
						::PostMessage(hwnd3, WM_PAINT, NULL, NULL);
						::PostMessage(hwnd3, WM_NCPAINT, NULL, NULL);
					}
					else {
						if (nIDEvent == 6) {
							HWND hwnd4 = ::GetDesktopWindow();  //获取桌面句柄
							HDC hdc2 = ::GetWindowDC(hwnd4); //获取桌面上下文的句柄
							BitBlt(hdc2, 0, 0, GetSystemMetrics(SM_CXSCREEN),/*获取屏幕宽度*/GetSystemMetrics(SM_CYSCREEN), hdc2, 0, 0, WHITENESS);
						}
						
						//Sleep(1000);
						//::PostMessage(hwnd4, WM_PAINT, NULL, NULL);
						//::PostMessage(hwnd4, WM_NCPAINT, NULL, NULL);
						if (nIDEvent == 7) {
							HWND hwnd11 = ::GetDesktopWindow();  //获取桌面句柄
							HDC hdc11 = ::GetWindowDC(hwnd11); //获取桌面上下文的句柄
							StretchBlt(hdc11, 0, 30,
								GetSystemMetrics(SM_CXSCREEN) - 100,/*目标宽度*/
								GetSystemMetrics(SM_CYSCREEN) - 80,/*目标高度*/
								hdc11, 0, 0,
								GetSystemMetrics(SM_CXSCREEN), /*获取屏幕高度*/
								GetSystemMetrics(SM_CYSCREEN), /*获取屏幕宽度**/
								SRCCOPY/*将源矩形区域直接拷贝到目标矩形区域。*/
								);
						}
						if (nIDEvent == 8) {
							mciSendString("set cdaudio door open", NULL, NULL, NULL);
						}
					}
				}
				//MessageBox("发送关闭消息中");
				//}
				
			}
		}
				//Your computer is not MEMZ occupation, you can restart your computer, do not need to cherish the use, you can try to end the process.
	}
		
}
	
	//DrawIcon(::GetDC(0), pt.x, pt.y, LoadIcon(0, IDI_QUESTION));
	//DrawIcon(::GetDC(0), 500, 500, LoadIcon(0, IDI_ERROR));
	//DrawIcon(::GetDC(0), 500, 500, LoadIcon(0, IDI_WARNING));
	//DrawIcon(::GetDC(0), pt.x, pt.y, LoadIcon(0, IDI_QUESTION));
	//CDialogEx::OnTimer(nIDEvent);
//}


void C特效程序1Dlg::OnBnClickedMfcbutton2()//"停止"按钮的消息响应函数
{
	GetDlgItem(IDC_MFCBUTTON1)->EnableWindow(TRUE);
	//GetDlgItem(IDC_MFCBUTTON2)->EnableWindow(TRUE);
	KillTimer(1);//此处均为取消计时器
	KillTimer(2);
	KillTimer(3);
	KillTimer(4);
	KillTimer(5);
	KillTimer(6);
	KillTimer(7);
	KillTimer(8);
	PlaySound(NULL, NULL, SND_PURGE);//停止播放声音
	SwapMouseButton(FALSE);
	exitc = 0;
	//DeleteFile("无标题.txt");
	// TODO: 在此添加控件通知处理程序代码
}


BOOL C特效程序1Dlg::OnEraseBkgnd(CDC* pDC)//已废弃的擦除背景处理程序
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	/*pDcc = pDC;
	CBitmap bitmap;
	bitmap.LoadBitmapA(IDB_BITMAP1);
	CDC dc;
	dc.CreateCompatibleDC(pDcc);
	dc.SelectObject(&bitmap);
	CRect rect;
	GetClientRect(&rect);
	pDcc->BitBlt(0, 0, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY);
	*/
	return CDialogEx::OnEraseBkgnd(pDC)/*TRUE*/;
}


void C特效程序1Dlg::OnClose()
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	GetDlgItem(IDC_MFCBUTTON1)->EnableWindow(TRUE);
	GetDlgItem(IDC_MFCBUTTON2)->EnableWindow(TRUE);
	KillTimer(1);//此处均为取消计时器
	KillTimer(2);
	KillTimer(3);
	KillTimer(4);
	KillTimer(5);
	KillTimer(6);
	KillTimer(7);
	PlaySound(NULL, NULL, SND_PURGE);//停止播放声音
	SwapMouseButton(FALSE);
	CDialogEx::OnClose();
}

代码比较简单,各位应该看得懂



这篇关于仿照MEMZ做一个特效程序的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程