亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C++實(shí)現(xiàn)添加桌面右鍵新建菜單

 更新時(shí)間:2016年01月05日 09:36:03   投稿:hebedich  
本文給大家匯總了3個(gè)版本的C++實(shí)現(xiàn)添加桌面右鍵新建菜單的代碼,陸陸續(xù)續(xù)寫的,有需要的小伙伴可以根據(jù)自己的需求來選擇

對于程序員來說,新建一個(gè)cpp文件是再頻繁不過的事情了。

為了方便,我們習(xí)慣在桌面右鍵新建文件,而不是新建一個(gè)文本文檔,然后修改后綴名。

百度谷歌查詢了一下,終于知道如何添加注冊表。

手癢,抽出時(shí)間用cpp寫了一個(gè)程序,方便以后操作。

客戶需求是永遠(yuǎn)無法滿足的,經(jīng)同學(xué)測試,陸續(xù)寫了三個(gè)版本。

接下來直接貼代碼~

第一個(gè)版本,只能添加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\\.c\\ShellNew\" /v \"NullFile\" /t REG_SZ");
}

void work_2() {
  system("reg add \"HKEY_CLASSES_ROOT\\.cpp\\ShellNew\" /v \"NullFile\" /t REG_SZ");
}

void work_3() {
  system("reg add \"HKEY_CLASSES_ROOT\\.java\\ShellNew\" /v \"NullFile\" /t REG_SZ");
}

int main() {
  printf("Add registry for C, C++ and Java\n");
  printf("Author: Haipz\nSchool: HDU\n");
  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] != '\0'; ++i) {
    printf("Working...\n");
    if (s[i] == '1') work_1();
    else if (s[i] == '2') work_2();
    else if (s[i] == '3') work_3();
    else printf("%c is a wrong enter!\n", s[i]);
  }
  system("pause");
  return 0;
}

第二個(gè)版本,精簡了代碼,支持添加用戶輸入的后綴。

 /*
 * Author: Haipz
 * School: HDU
 * File Name: registry2.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 a[1024];
 char b[1024] = "reg add \"HKEY_CLASSES_ROOT\\.";
 char c[1024] = "\\ShellNew\" /v \"NullFile\" /t REG_SZ";
 
 void work(char* a) {
   strcat(b, a);
   strcat(b, c);
   system(b);
 }
 
 int main() {
   printf("Function: Add registry to build a new file simply!\n");
   printf("Author: Haipz\nSchool: HDU\n");
   printf("Example: Enter c to add C and enter cpp to add C++.\n");
   printf("Your opion: ");
   gets(a);
   work(a);
   system("pause");
   return 0;
 }

第三個(gè)版本,支持多次添加,并允許刪除已添加的注冊表。

/*
 * Author: Haipz
 * School: HDU
 * File Name: registry2.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 key[1024];
char a[1024];

void add(char* t) {
  char b[1024] = "reg add \"HKEY_CLASSES_ROOT\\.";
  char c[1024] = "\\ShellNew\" /v \"NullFile\" /t REG_SZ";
  strcat(b, t);
  strcat(b, c);
  system(b);
}

void del(char* t) {
  char d[1024] = "reg delete \"HKEY_CLASSES_ROOT\\.";
  char e[1024] = "\\ShellNew\" /f";
  strcat(d, t);
  strcat(d, e);
  system(d);
}

int main() {
  printf("Function: Build a new file simply!\n");
  printf("Author: Haipz\nSchool: HDU\n");
  printf("Example: Enter \"c\" to add C and enter \"cpp\" to add C++;\n");
  printf("     Enter \"-c\" to delete C.\n");
  do {
    printf("Your opion: ");
    gets(a);
    if (a[0] == '-') del(a + 1);
    else add(a);
    printf("Enter \"r\" to run again or any other key to quit: ");
    gets(key);
  } while (key[0] == 'r');
  return 0;
}

打包下載地址:

http://xiazai.jb51.net/201601/yuanma/Regedity(jb51.net).zip

注意,如果系統(tǒng)提示缺少某dll文件,請到網(wǎng)上下載,并復(fù)制到C:\Windows\System32目錄下。

相關(guān)文章

  • Qt讀取和寫入配置(ini)文件

    Qt讀取和寫入配置(ini)文件

    ini文件在windows系統(tǒng)中可以存儲(chǔ)需要持久保存的配置信息,本文主要介紹了Qt讀取和寫入配置(ini)文件,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-09-09
  • C語言輸出教學(xué)日歷表的方法實(shí)例

    C語言輸出教學(xué)日歷表的方法實(shí)例

    最近幫朋友做一些C語言的練習(xí)題,期間遇到了個(gè)比較有意思的題目,下面這篇文章主要給大家介紹了關(guān)于C語言輸出教學(xué)日歷表的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-06-06
  • Qt之使用GraphicsView框架實(shí)現(xiàn)思維導(dǎo)圖的示例

    Qt之使用GraphicsView框架實(shí)現(xiàn)思維導(dǎo)圖的示例

    思維導(dǎo)圖可以更方便的整理知識(shí),本文主要介紹了Qt之使用GraphicsView框架實(shí)現(xiàn)思維導(dǎo)圖的示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-05-05
  • C++指針與數(shù)組:指針詳解

    C++指針與數(shù)組:指針詳解

    本文從初學(xué)者的角度,深入淺出地講解C++中的指針、數(shù)組指針,對最?;煜囊脗鬟f、值傳遞和指針傳遞做了區(qū)處,需要的朋友可以參考下
    2021-09-09
  • C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(鏈表)

    C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(鏈表)

    這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • c++與c中的數(shù)組初始化默認(rèn)值如何為0

    c++與c中的數(shù)組初始化默認(rèn)值如何為0

    這篇文章主要介紹了c++與c中的數(shù)組初始化默認(rèn)值如何為0問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-08-08
  • C++中關(guān)于set刪除的一些坑

    C++中關(guān)于set刪除的一些坑

    這篇文章主要介紹了C++中關(guān)于set刪除的一些坑,因?yàn)檫@個(gè)問題浪費(fèi)了很多的時(shí)間,所以想著分享出來給大家,方便同樣遇到這個(gè)問題的朋友們,有需要的朋友們下面來一起看看吧。
    2017-02-02
  • c語言網(wǎng)絡(luò)編程-標(biāo)準(zhǔn)步驟(比較簡單)

    c語言網(wǎng)絡(luò)編程-標(biāo)準(zhǔn)步驟(比較簡單)

    這篇文章主要介紹了c語言網(wǎng)絡(luò)編程-標(biāo)準(zhǔn)步驟(比較簡單),需要的朋友可以參考下
    2014-01-01
  • Qt實(shí)現(xiàn)部件透明陰影效果與不規(guī)則窗體詳解

    Qt實(shí)現(xiàn)部件透明陰影效果與不規(guī)則窗體詳解

    這篇文章主要為大家詳細(xì)介紹了Qt實(shí)現(xiàn)部件透明陰影效果與不規(guī)則窗體的相關(guān)方法,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下
    2023-01-01
  • Linux下C語言實(shí)現(xiàn)貪吃蛇小游戲

    Linux下C語言實(shí)現(xiàn)貪吃蛇小游戲

    這篇文章主要為大家詳細(xì)介紹了Linux下C語言實(shí)現(xiàn)貪吃蛇小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-03-03

最新評論