有没有大佬独具慧眼,觉得这是个好东西的?(违规紫衫)
/*
* 版权所有:Henrylin11
* 未经许可,禁止冒充
*/
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<shlobj.h>
#include<stdlib.h>
#include<winreg.h>
#define appico IDI_APPLICATION
#define askico IDI_QUESTION
#define winlogo IDI_WINLOGO
#define warico IDI_WARNING
#define erokico IDI_ERROR
#define infoico IDI_INFORMATION
namespace winp {
POINT getmourest = {0, 0};
const int fcyan = FOREGROUND_GREEN | FOREGROUND_BLUE;
const int fyellow = FOREGROUND_RED | FOREGROUND_GREEN;
const int fpurple = FOREGROUND_RED | FOREGROUND_BLUE;
const int fitst = FOREGROUND_INTENSITY;
const int bcyan = BACKGROUND_GREEN | BACKGROUND_BLUE;
const int byellow = BACKGROUND_RED | BACKGROUND_GREEN;
const int bpurple = BACKGROUND_RED | BACKGROUND_BLUE;
const int bitst = BACKGROUND_INTENSITY;
HANDLE HOUT = GetStdHandle(STD_OUTPUT_HANDLE);//获得标准输出的句柄
typedef long long OLENGTH;
inline void _pause() {
_getch();
return;
}
inline void moupos(int x, int y) {
SetCursorPos(x, y);
return;
}
POINT getmou() {
POINT cursor;
HWND hwnd = GetForegroundWindow();
HDC hdc = GetWindowDC(hwnd);
GetCursorPos(&cursor);
getmourest.x = cursor.x;
getmourest.y = cursor.y;
return cursor;
}
BOOL StringToClipBoard(char* srcString) {
BOOL bResult = FALSE;
DWORD dwLength = strlen(srcString);
HANDLE hGlobalMemory = GlobalAlloc(GHND, dwLength + 1);
LPBYTE lpGlobalMemory = (LPBYTE)GlobalLock(hGlobalMemory);
if ( NULL != lpGlobalMemory ) {
strcpy((char*)lpGlobalMemory, srcString);
GlobalUnlock(hGlobalMemory);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_TEXT, hGlobalMemory);
CloseClipboard();
bResult = TRUE;
}
return bResult;
}
void Icon(OLENGTH x = (-1), OLENGTH y = (-1), LPSTR ico = infoico) {
POINT cursor;
HWND hwnd = GetForegroundWindow();
HDC hdc = GetWindowDC(hwnd);
GetCursorPos(&cursor);
if (x >= 0) {
cursor.x = x;
}
if (y >= 0) {
cursor.y = y;
}
DrawIcon(hdc, cursor.x, cursor.y, LoadIcon(NULL, ico));
return;
}
void DisTask() {
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;
}
void AloTask() {
HKEY hkey;
DWORD value = 0;
RegCreateKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", &hkey);
RegSetValueEx(hkey, "DisableTaskMgr", NULL, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
RegCloseKey(hkey);
return;
}
void WinTop() {
HWND hwnd = GetForegroundWindow();
SetWindowPos(hwnd, HWND_TOPMOST, 200, 200, 50, 50, SWP_NOMOVE | SWP_NOSIZE);
}
void WinPos(DWORD a, DWORD b, DWORD c, DWORD d) {
HWND hwnd = GetForegroundWindow();
MoveWindow(hwnd, a, b, c, d, TRUE);
}
/*
此功能暂时有问题。
void turn(){
DEVMODE dm;
ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(dm);
if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm)) {
// swap height and width
DWORD dwTemp = dm.dmPelsHeight;
dm.dmPelsHeight = dm.dmPelsWidth;
dm.dmPelsWidth = dwTemp;
// determine new orientaion
switch (dm.dmDisplayOrientation) {
case DMDO_DEFAULT:
dm.dmDisplayOrientation = DMDO_270;
break;
case DMDO_270:
dm.dmDisplayOrientation = DMDO_180;
break;
case DMDO_180:
dm.dmDisplayOrientation = DMDO_90;
break;
case DMDO_90:
dm.dmDisplayOrientation = DMDO_DEFAULT;
break;
default:
// unknown orientation value
break;
}
long lRet = ChangeDisplaySettings(&dm, 0);
if (DISP_CHANGE_SUCCESSFUL != lRet) {
// add exception handling here
}
}
}
*/
void down(int vk) {
keybd_event(vk, 0, 0, 0);
}
void up(int vk) {
keybd_event(vk, 0, KEYEVENTF_KEYUP, 0);
}
void press(int vk) {
keybd_event(vk, 0, 0, 0);
keybd_event(vk, 0, KEYEVENTF_KEYUP, 0);
}
void mouseprs(DWORD time = 10) {
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
Sleep(time);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
void FBL(int height, int width) {
DEVMODE dm;
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
dm.dmPelsHeight = height;
dm.dmPelsWidth = width;
ChangeDisplaySettings(&dm, CDS_RESET);
}
void FullScreen() {
keybd_event(VK_MENU, 0x38, 0, 0);
keybd_event(VK_RETURN, 0x1c, 0, 0);
keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0);
}//强制全屏
bool gotoxy(int x, int y) {
COORD pos;//COORD是一种自带结构体,表示一个字符在控制台屏幕上的坐标
pos.X = y, pos.Y = x;
return SetConsoleCursorPosition(HOUT, pos);//定位光标的函数
}
bool show_cursor(BOOL hide) {
CONSOLE_CURSOR_INFO cciCursor;
if (GetConsoleCursorInfo(HOUT, &cciCursor)) {
cciCursor.bVisible = hide;
SetConsoleCursorInfo(HOUT, &cciCursor);
return 1;
}
return 0;
}
inline bool set_color(int color) {
return SetConsoleTextAttribute(HOUT, color);
}
inline void Incproporty(unsigned int priority_x = REALTIME_PRIORITY_CLASS, unsigned int priority_y = THREAD_PRIORITY_TIME_CRITICAL) {
SetPriorityClass(GetCurrentProcess(), priority_x);
SetThreadPriority(GetCurrentThread(), priority_y);
return;
}
BOOL SelfDel() {
SHELLEXECUTEINFO sei;
TCHAR szModule[MAX_PATH], szComspec[MAX_PATH], szParams[MAX_PATH];
if ((GetModuleFileName(0, szModule, MAX_PATH) != 0) &&
(GetShortPathName(szModule, szModule, MAX_PATH) != 0) &&
(GetEnvironmentVariable("COMSPEC", szComspec, MAX_PATH) != 0)) {
lstrcpy(szParams, "/c del ");
lstrcat(szParams, szModule);
lstrcat(szParams, " > nul");
sei.cbSize = sizeof(sei);
sei.hwnd = 0;
sei.lpVerb = "Open";
sei.lpFile = szComspec;
sei.lpParameters = szParams;
sei.lpDirectory = 0;
sei.nShow = SW_HIDE;
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
if (ShellExecuteEx(&sei)) {
SetPriorityClass(sei.hProcess, IDLE_PRIORITY_CLASS);
Incproporty();
SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, szModule, 0);
return TRUE;
}
}
return FALSE;
}
bool managerun(char* programPath) {
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.lpVerb = "runas";
sei.lpFile = programPath;
if (!ShellExecuteEx(&sei)) {
GetLastError();
return 0;
}
return 1;
}
}