对于程序员来说,新建一个cpp文件是再频繁不过的事情了。
为了方便,我们习惯在桌面右键新建文件,而不是新建一个文本文档,然后修改后缀名。
手痒,抽出时间用cpp写了一个程序,方便以后操作。
客户需求是永远无法满足的,经同学测试,陆续写了三个版本。
接下来直接贴代码~
第一个版本,只能添加c、cpp、java三种后缀。
1 /* 2 * Author: Haipz 3 * School: HDU 4 * File Name: registry1.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 s[1024], buffer[128], result[1024*4]; 24 25 void work_1() { 26 system("reg add \"HKEY_CLASSES_ROOT\\.c\\ShellNew\" /v \"NullFile\" /t REG_SZ"); 27 } 28 29 void work_2() { 30 system("reg add \"HKEY_CLASSES_ROOT\\.cpp\\ShellNew\" /v \"NullFile\" /t REG_SZ"); 31 } 32 33 void work_3() { 34 system("reg add \"HKEY_CLASSES_ROOT\\.java\\ShellNew\" /v \"NullFile\" /t REG_SZ"); 35 } 36 37 int main() { 38 printf("Add registry for C, C++ and Java\n"); 39 printf("Author: Haipz\nSchool: HDU\n"); 40 printf("1 for C;\n2 for C++;\n3 for Java.\n"); 41 printf("Example: 12 to add C and C++.\n"); 42 printf("Please make choice(s): "); 43 gets(s); 44 for (int i = 0; s[i] != '\0'; ++i) { 45 printf("Working...\n"); 46 if (s[i] == '1') work_1(); 47 else if (s[i] == '2') work_2(); 48 else if (s[i] == '3') work_3(); 49 else printf("%c is a wrong enter!\n", s[i]); 50 } 51 system("pause"); 52 return 0; 53 } |