欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

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

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

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

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

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

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

客戶需求是永遠(yuǎn)無法滿足的,經(jīng)同學(xué)測(cè)試,陸續(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è)版本,精簡(jiǎn)了代碼,支持添加用戶輸入的后綴。

 /*
 * 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è)版本,支持多次添加,并允許刪除已添加的注冊(cè)表。

/*
 * 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文件,請(qǐng)到網(wǎng)上下載,并復(fù)制到C:\Windows\System32目錄下。

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有