极域杀手v2.0
2023-09-18 15:14:45
发布于:浙江
#include <windows.h>
#include <TlHelp32.h>
#include <conio.h>
#include <cstdio>
inline bool KEY_DOWN(int vkey){
return ((GetAsyncKeyState(vkey) & 0x8000) ? 1:0);
}
typedef struct tagWNDINFO
{
DWORD dwProcessId;
HWND hWnd;
} WNDINFO, *LPWNDINFO;
BOOL CALLBACK MyEnumProc(HWND hWnd,LPARAM lParam)//枚举所有进程
{
DWORD dwProcId;
GetWindowThreadProcessId(hWnd, &dwProcId);
LPWNDINFO pInfo=(LPWNDINFO)lParam;
if(dwProcId==pInfo->dwProcessId)
{
pInfo->hWnd = hWnd;
return FALSE;
}
return TRUE;
}
HWND GetProcessMainWnd(DWORD dwProcessId)//获取给定进程ID的窗口handle
{
WNDINFO wi;
wi.dwProcessId = dwProcessId;
wi.hWnd = NULL;
EnumWindows(MyEnumProc,(LPARAM)&wi);
return wi.hWnd;
}
HWND GetWndHwnd(char *strExeName)
{
PROCESSENTRY32 pe32;
pe32.dwSize = sizeof(pe32);
HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
return NULL;
}
BOOL bMore = ::Process32First(hProcessSnap,&pe32);
while (bMore)
{
//if(pe32.szExeFile == exeName)//找到了进程
if(strcmp(pe32.szExeFile,strExeName) == 0)
{
HWND game_window_hwnd=GetProcessMainWnd(pe32.th32ProcessID );
if (NULL != game_window_hwnd)
{
::CloseHandle(hProcessSnap);
return game_window_hwnd;
}
}
bMore = ::Process32Next(hProcessSnap,&pe32);
}
::CloseHandle(hProcessSnap);
return NULL;
}
int main(){
bool flag = 1;
while(1){
if(KEY_DOWN(VK_SPACE)){
flag = !flag;
}
if(flag){
printf("强制最小化: 开启\r");
ShowWindow(GetWndHwnd((char*)"StudentMain.exe"),SW_HIDE);
}else{
printf("强制最小化: 关闭\r");
}
Sleep(150);
}
return 0;
}
这里空空如也
有帮助,赞一个