C++利用注册表添加桌面右键新建菜单
作者:网络转载 发布时间:[ 2016/1/7 13:54:47 ] 推荐标签:测试开发技术 .NET
第二个版本,精简了代码,支持添加用户输入的后缀。
1 /*
2 * Author: Haipz
3 * School: HDU
4 * File Name: registry2.0.cpp
5 */
6 #include <cstdio>
7 #include <cmath>
8 #include <ctime>
9 #include <cctype>
10 #include <cstring>
11 #include <cstdlib>
12 #include <climits>
13 #include <cfloat>
14 #include <iostream>
15 #include <vector>
16 #include <stack>
17 #include <queue>
18 #include <set>
19 #include <map>
20 #include <algorithm>
21 using namespace std;
22
23 char a[1024];
24 char b[1024] = "reg add "HKEY_CLASSES_ROOT\.";
25 char c[1024] = "\ShellNew" /v "NullFile" /t REG_SZ";
26
27 void work(char* a) {
28 strcat(b, a);
29 strcat(b, c);
30 system(b);
31 }
32
33 int main() {
34 printf("Function: Add registry to build a new file simply! ");
35 printf("Author: Haipz School: HDU ");
36 printf("Example: Enter c to add C and enter cpp to add C++. ");
37 printf("Your opion: ");
38 gets(a);
39 work(a);
40 system("pause");
41 return 0;
42 }
第三个版本,支持多次添加,并允许删除已添加的注册表。
1 /*
2 * Author: Haipz
3 * School: HDU
4 * File Name: registry2.0.cpp
5 */
6 #include <cstdio>
7 #include <cmath>
8 #include <ctime>
9 #include <cctype>
10 #include <cstring>
11 #include <cstdlib>
12 #include <climits>
13 #include <cfloat>
14 #include <iostream>
15 #include <vector>
16 #include <stack>
17 #include <queue>
18 #include <set>
19 #include <map>
20 #include <algorithm>
21 using namespace std;
22
23 char key[1024];
24 char a[1024];
25
26 void add(char* t) {
27 char b[1024] = "reg add "HKEY_CLASSES_ROOT\.";
28 char c[1024] = "\ShellNew" /v "NullFile" /t REG_SZ";
29 strcat(b, t);
30 strcat(b, c);
31 system(b);
32 }
33
34 void del(char* t) {
35 char d[1024] = "reg delete "HKEY_CLASSES_ROOT\.";
36 char e[1024] = "\ShellNew" /f";
37 strcat(d, t);
38 strcat(d, e);
39 system(d);
40 }
41
42 int main() {
43 printf("Function: Build a new file simply! ");
44 printf("Author: Haipz School: HDU ");
45 printf("Example: Enter "c" to add C and enter "cpp" to add C++; ");
46 printf(" Enter "-c" to delete C. ");
47 do {
48 printf("Your opion: ");
49 gets(a);
50 if (a[0] == '-') del(a + 1);
51 else add(a);
52 printf("Enter "r" to run again or any other key to quit: ");
53 gets(key);
54 } while (key[0] == 'r');
55 return 0;
56 }
打包下载地址:
http://files.cnblogs.com/haipzm/Regedity.zip
注意,如果系统提示缺少某dll文件,请到网上下载,并复制到C:WindowsSystem32目录下。
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11热门文章
常见的移动App Bug??崩溃的测试用例设计如何用Jmeter做压力测试QC使用说明APP压力测试入门教程移动app测试中的主要问题jenkins+testng+ant+webdriver持续集成测试使用JMeter进行HTTP负载测试Selenium 2.0 WebDriver 使用指南