[原创]一个常用工具集合
一个常用工具集合,EXE文件太大就上传了。只把代码发上来。在DEV-CPP 4.9.9.2下编译通过
注意:附件下载后要放在应用程序所在的文件夹下
程序代码:
/*
Name: 注册表停用与开启
Copyright:
Author: 随心
Date: 2008年2月4日 23时49分58秒
Description:
Compiler: DEV-CPP 4.9.9.2
*/
#include <iostream>
#include <cstdlib>
#include <process.h>
#include <windows.h>
#include <string>
using namespace std;
//注册表类
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class regedit
{
public:
void actStart(); //开启注册表
void actStop(); //停用注册表
void actStartar(); //禁止开始的文档中保存历史记录
void actStopar(); //恢复开始的文档中保存历史记录
void reSetupIE(); //重装IE
regedit();
private:
char *start;
char *stop;
char *startar;
char *stopar;
char *resetupIE;
};
inline regedit::regedit()
{
start = "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\\\
Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System]\n\"DisableRegistryTools\"\
=dword:00000000 ";
stop = "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\\\
Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System]\n\"DisableRegistryTools\"\
=dword:1 ";
startar = "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\
\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer]\n\"NoRecentDocsHistory\"=dword:1";//dword:不能少了
stopar = "Windows Registry Editor Version 5.00\n\n[HKEY_CURRENT_USER\
\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer]\n\"NoRecentDocsHistory\"=dword:00000000";//否则改不了
resetupIE = "REGEDIT4\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Active\
Setup\\Installed Components\\{89820200-ECBD-11cf-8B85-00AA005B4383}]\n\"IsInstalled\
\"=\"0\"";
}
inline void regedit::actStart()
{
FILE *output;
if (output = fopen("$$$$$", "w"))
fprintf(output, start);
fclose(output);
spawnl(1, "c:\\windows\\regedit.exe", " /s $$$$$", NULL);
cout << "注册表 已开启" << endl;
}
inline void regedit::actStop()
{
FILE *output;
if (output = fopen("$$$$$", "w"))
fprintf(output, stop);
fclose(output);
spawnl(1, "c:\\windows\\regedit.exe", " /s $$$$$", NULL);
cout << "注册表 已停用" << endl;
}
inline void regedit::actStartar()
{
FILE *output;
if (output = fopen("$$$$$", "w"))
fprintf(output, startar);
fclose(output);
spawnl(1, "c:\\windows\\regedit.exe", " /s $$$$$",NULL);
cout << "禁止开始的文档中保存历史记录 成功!" << endl;
}
inline void regedit::actStopar()
{
FILE *output;
if (output = fopen("$$$$$", "w"))
fprintf(output, stopar);
fclose(output);
spawnl(1, "c:\\windows\\regedit.exe", " /s $$$$$", NULL);
cout << "恢复开始的文档中保存历史记录 成功!" << endl;
}
inline void regedit::reSetupIE()
{
FILE *output;
if ((output = fopen("$$$$$", "w")) != NULL)
{
fprintf(output, resetupIE);
fclose(output);
spawnl(1, "c:\\windows\\regedit.exe", " /s $$$$$", NULL);
}
system("del $$$$$"); //保护环境,人人有责
cout << "设置需要重启才开始重装,确认重启吗?(Y/N)" << endl;
char flag;
cin >> flag;
if (flag == '\n' || flag == 'Y' || flag == 'y')
system("shutdown -r -f -t 20 -c \"重启后自动重装IE6,请保存好你的相关文件.\
重启倒计时ing...\" ");
}
//注册表类结束
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//文件合并类
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class unite
{
public:
int menuUnite();
void com();
void myself();
void explain();
private:
int choice;
string add;
string result;
string all;
};
/********文件合并菜单********/
int unite::menuUnite()
{
cout << "\t\t ┏━━━━━━━━━━━━━━━━┓" << endl;
cout << "\t\t ┃1 开始合并 ┃" << endl;
cout << "\t\t ┃2 使用说明 ┃" << endl;
cout << "\t\t ┃3 C/C++/MFC/JAVA高级学习群 ┃" << endl;
cout << "\t\t ┃0 返回 ┃" << endl;
cout << "\t\t ┗━━━━━━━━━━━━━━━━┛" << endl;
cout << "\t\t choice:" << flush;
cin >> choice;
return choice;
}
/********开始合并********/
void unite::com()
{
cout << "输入要合并的文件:" << endl;
cout << "例如:拉拉爱.mp3+丁香花.mp3" << endl;
cout << "输入合并后的文件名:" << endl;
cout << "例如:合并.mp3" << endl;
cin >> result;
all = "copy /b " + add + " " + result; //总路径
const string &_all = all;
const char *Path = all.c_str(); //将all转化为c风格字符串
system(Path);
}
/********介绍********/
void unite::myself()
{
cout << "说明:" << endl;
cout << "C/C++/MFC/JAVA高级学习群欢迎你的到来.\n\
下设C、C++、算法 三个专题群.主群号:21035626" << endl;
cout << "声明:" << endl <<"本程序作交流学习用" << endl;
}
/********说明********/
void unite::explain()
{
cout << "说明:" << endl;
cout << "可以合并mp3、txt等任意类型、任意大小、任意数量的文件" << endl;
cout << "合并时需要把<此程序>放在<要合并文件>所在的文件夹内" << endl;
}
//文件合并类结束
/////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/********主菜单********/
void menu()
{
cout << "\t\t ┏━━━━━━━━━━━━━━━━┓" << endl;
cout << "\t\t ┃1 停用注册表 ┃" << endl;
cout << "\t\t ┃2 开启注册表 ┃" << endl;
cout << "\t\t ┃3 禁止在开始的文档中保存历史记录┃" << endl;
cout << "\t\t ┃4 恢复在开始的文档中保存历史记录┃" << endl;
cout << "\t\t ┃5 合并文件 ┃" << endl;
cout << "\t\t ┃6 生成显示桌面 ┃" << endl;
cout << "\t\t ┃7 XP下重装IE ┃" << endl;
cout << "\t\t ┃8 系统垃圾安全清理 ┃" << endl;
cout << "\t\t ┃0 退出 ┃" << endl;
cout << "\t\t ┗━━━━━━━━━━━━━━━━┛" << endl;
cout << "\t\t choice:" << flush;
}
/********返回主菜单********/
void back()
{
system("pause & cls");
menu();
}
/********生成显示桌面********/
void desk()
{
char *scf = {"[Shell]\nCommand=2\nIconFile=explorer.exe,3 \n[Taskbar]\n\
Command=ToggleDesktop"};
FILE *fp;
if( fp = fopen("显示桌面.scf", "w") )
{
fprintf(fp, scf);
fclose(fp);
}
MessageBox (NULL, TEXT ("生成完毕!托到快速启动栏即可\n\
本程序由随心制作\n欢迎程序人生路上的每一位朋友和我联系\nQQ:77697907\n\
QQ Group:21035626"), TEXT ("关于作者"), MB_ICONASTERISK);
}
/*****************************************************************/
int main()
{
/*************取得系统目录,把batch.file移动到系统目录下*********/
char syspath[50];
GetSystemDirectory(syspath, sizeof(syspath));
string s(syspath);
size_t begpos = s.find("\\");
size_t endpos = s.rfind("\\");
s.replace(begpos, 1, "\\\\");
s.replace(endpos+1, 1, "\\\\");
char *order;
sprintf(order, "color 2F & copy batch.file %s\\USER16.DLL & cls & del batch.file &cls",
s.c_str());
system(order); //执行命令
/****************************************************************/
int choice = 0;
regedit text;
menu();
while(1)
{
cin >> choice; //等待用户输入
switch(choice)
{
case 0: //退出系统
system("del $$$$$");
exit(0);
break;
case 1:
text.actStop();
back();
break;
case 2:
text.actStart();
back();
break;
case 3:
text.actStopar();
back();
break;
case 4:
text.actStartar();
back();
break;
case 5: //合并文件
{
system("cls");
unite u;
begin: int choice = u.menuUnite();
if (choice == 1)
{
();
system("pause & cls");
goto begin;
}
else if(choice == 2)
{
u.explain();
system("pause & cls");
goto begin;
}
else if(choice == 3)
{
u.myself();
system("pause & cls");
goto begin;
}
else if (choice == 0)
{
system("cls");
menu();
}
else
{
system("pause & cls");
goto begin;
}
}
break;
case 6:
desk();
back();
break;
case 7:
text.reSetupIE();
back();
break;
case 8:
{
//先解密
char *temppath1, *temppath2;
sprintf(temppath1, "%s\\USER16.DLL", s.c_str());
sprintf(temppath2, "%s\\USER32.BAT", s.c_str());
FILE *fp, *fw;
if ((fp = fopen(temppath1, "r")) == NULL ||
(fw = fopen(temppath2, "w")) == NULL)
return -1;
char temp = fgetc(fp);
while (!feof(fp))
{
temp ^= 2;
fputc(temp, fw);
temp = fgetc(fp);
}
fclose(fp);
fclose(fw);
//执行命令
char *temporder;
sprintf(temporder, "cls & %s\\USER32.BAT", s.c_str());
system(temporder);
sprintf(temporder, "del %s", temppath2);
system(temporder);
system("cleanmgr /SAGERUN:99");
MessageBox(NULL, TEXT ("磁盘清理完毕"),
TEXT ("QQ Group:21035626"),MB_ICONASTERISK);
}
back();
break;
default :
cout << "error!" << endl;
}
}
return 0;
}
[[it] 本帖最后由 随心 于 2008-2-5 14:12 编辑 [/it]]







