WIN7/XP用注册表关联指定后缀名和打开程序(C程序实现)
2012-08-07 16:00
351 查看
在前一篇文章中/article/1847954.html,已经介绍了用注册表关联指定的后缀名和打开程序的原理,而且了详细的手动操作过程。本文通过C程序实现上文的关联功能。
本文的完整代码在http://download.csdn.net/detail/arvon2012/4482694,
对刚接触注册表编程的朋友请看入门文章/article/1847950.html
这里其实就是用代码模拟手工操作,完全一样的步骤实现关联。有什么意见欢迎留言!谢谢!
步骤:
1.创建后缀键,并给后缀键传入默认值,设置好处理键
2.创建处理键,并设置打开程序
技术相关更多文章猛击:哇啦天堂论坛技术区
本文的完整代码在http://download.csdn.net/detail/arvon2012/4482694,
对刚接触注册表编程的朋友请看入门文章/article/1847950.html
这里其实就是用代码模拟手工操作,完全一样的步骤实现关联。有什么意见欢迎留言!谢谢!
步骤:
1.创建后缀键,并给后缀键传入默认值,设置好处理键
//create .seve if (ERROR_SUCCESS!=RegCreateKey(HKEY_CLASSES_ROOT,L".seve",&hKey)) { printf("创建子键失败!\n"); return 0; } else { printf("create .seve!\n"); } RegCloseKey(hKey); if(RegOpenKeyEx(HKEY_CLASSES_ROOT,L".arv",0,KEY_ALL_ACCESS,&hKey)!=ERROR_SUCCESS) { printf("创建HKEY失败!\n"); return 0; } //set value LPCWSTR szValueName1 = L""; LPCWSTR szValueDate1=L"seven"; UINT cbLen=wcslen(szValueDate1); if(RegSetValueExW(hKey,NULL,0,REG_SZ,(const unsigned char *)szValueDate1,cbLen*2)==ERROR_SUCCESS) { printf("set value!\n"); } else { printf("创建REG_SZ键值失败!\n"); return 0; } RegCloseKey(hKey);
2.创建处理键,并设置打开程序
//create opofile if (ERROR_SUCCESS!=RegCreateKey(HKEY_CLASSES_ROOT,L"opofile\\shell\\open\\command",&hKey)) { printf("创建子键失败!\n"); return 0; } else { printf("create opofile!\n"); } szValueDate1=L"\"F:\\SRC\\FILTER\\JUMP\\Debug\\JUMP.exe\" \"%1\""; cbLen=wcslen(szValueDate1); if(RegSetValueExW(hKey,NULL,0,REG_SZ,(const unsigned char *)szValueDate1,cbLen*2)==ERROR_SUCCESS) { printf("set opofile value!\n"); } else { printf("创建REG_SZ键值失败!\n"); return 0; } RegCloseKey(hKey); getchar();
技术相关更多文章猛击:哇啦天堂论坛技术区
相关文章推荐
- WIN7/XP用注册表关联指定后缀名和打开程序(手动【图文】和C编程两种实现)
- 与众不同 windows phone (38) - 8.0 关联启动: 使用外部程序打开一个文件或URI, 关联指定的文件类型或协议
- Windows系统通过注册表实现打开CMD并定位到指定文件夹
- java操作注册表实现禁用指定程序
- java程序中指定某个浏览器打开网页的实现方法
- 如何在程序中实现关联指定的文件类型
- 重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议
- 与众不同 windows phone (38) - 8.0 关联启动: 使用外部程序打开一个文件或URI, 关联指定的文件类型或协议
- VC程序实现根据文件后缀名查询注册表并用查询结果运行打开程序打开对应文件
- JAVA实现用系统关联的程序打开文件
- 让自己的软件实现双击打开文件(修改注册表设置关联)
- java操作注册表实现禁用指定程序
- 编程实现双击某个文件用指定程序打开
- 如何在程序中实现关联指定的文件类型
- android 文件关联的方法 实现点击文件打开指定应用软件
- 调用Windows关联程序打开指定文件
- 重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议
- java程序中指定某个浏览器打开的实现方法
- 在程序中实现关联指定的文件类型
- java程序中实现打开 某个指定浏览器