本文给大家汇总了3个版本的C++实现添加桌面右键新建菜单的代码,陆陆续续写的,有需要的小伙伴可以根据自己的需求来选择
对于程序员来说,新建一个cpp文件是再频繁不过的事情了。
为了方便,我们习惯在桌面右键新建文件,而不是新建一个文本文档,然后修改后缀名。
百度谷歌查询了一下,终于知道如何添加注册表。
手痒,抽出时间用cpp写了一个程序,方便以后操作。
客户需求是永远无法满足的,经同学测试,陆续写了三个版本。
接下来直接贴代码~
第一个版本,只能添加c、cpp、java三种后缀。
/*
* Author: Haipz
* School: HDU
* File Name: registry1.0.cpp
*/
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cfloat>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
char s[1024], buffer[128], result[1024*4];
void work_1() {
system("reg add "HKEY_CLASSES_ROOT.cShellNew" /v "NullFile" /t REG_SZ");
}
void work_2() {
system("reg add "HKEY_CLASSES_ROOT.cppShellNew" /v "NullFile" /t REG_SZ");
}
void work_3() {
system("reg add "HKEY_CLASSES_ROOT.javaShellNew" /v "NullFile" /t REG_SZ");
}
int main() {
printf("Add registry for C, C++ and Javan");
printf("Author: HaipznSchool: HDUn");
printf("1 for C;n2 for C++;n3 for Java.n");
printf("Example: 12 to add C and C++.n");
printf("Please make choice(s): ");
gets(s);
for (int i = 0; s[i] != '