惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
博客园 - 【当耐特】
GbyAI
GbyAI
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
腾讯CDC
F
Fortinet All Blogs
IT之家
IT之家
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Help Net Security
V
Visual Studio Blog
小众软件
小众软件
Y
Y Combinator Blog

博客园 - RockyYu

策略模式 unity中的WWW通讯问题 需求分析的方法 用TlbImp.exe生成程序可调用的Dll C++程序引用Dll windows服务的安装和卸载 FFmpeg和GPL协议 List<T>的排序 C#POST数据,HttpWebRequest请求页面,HttpWebResponse返回数据 XMLHttpRequest的使用方法 错误: 无法生成临时类 图片滚动效果代码 - RockyYu - 博客园 一个不错的给图片添加说明文字的动态层的代码 - RockyYu - 博客园 截取中文字符串的js方法 js调用XML数据生成DIV 迭代器模式(Iterator Pattern) 创建CLR存储过程 JavaScript Boolean (逻辑)对象 - RockyYu JavaScript文件只在IE6下出错(“未结束的字符串常量”)的解决办法。
查询本地注册表,调用某后缀文件相应的执行程序,并打开文件
RockyYu · 2010-08-18 · via 博客园 - RockyYu

以下是查询注册表信息的代码: 

查找注册表中某后缀文件执行程序的代码

 1 private RegistryKeyStatus GetExePath(string suffix, ref string exePath)
 2 {
 3     RegistryKey regSuffixKey = Registry.ClassesRoot.OpenSubKey(suffix);
 4     if (regSuffixKey == null || regSuffixKey.GetValue(""== null)
 5         return RegistryKeyStatus.NonAvailable;
 6     string playerKey = regSuffixKey.GetValue("").ToString();
 7     RegistryKey regPlayerKey = Registry.ClassesRoot.OpenSubKey(playerKey + "\\shell\\open\\command");
 8     if (regPlayerKey == null)
 9         return RegistryKeyStatus.RegKeyNotFound;
10     string[] keys = regPlayerKey.GetValue("").ToString().Split('"');
11     foreach (string key in keys)
12     {
13         if (!string.IsNullOrEmpty(key.Trim()))
14         {
15             exePath = key;
16             break;
17         }
18     }
19     return RegistryKeyStatus.Available;
20 }
21  public enum RegistryKeyStatus
22 {
23     Available = 0,//可用
24      NonAvailable = 1,//无可用
25     RegKeyNotFound = 2,//未找到注册键
26 }

 执行的话,只需要调用Process.Start()就可以了。 

1 RegistryKeyStatus regKeyStatus = GetExePath(suffix, ref exePath);
2 Process.Start(exePath, "\"" + filePath + "\"");

注:上面的"\""一定要加,否则地址中有空格就可能找不到相应文件。