在C#中调用注册表获得Word的安装路径

.net 2.0

 1using Microsoft.Win32; 
 2
 3private string GetWordPath() 
 4
 5  RegistryKey key = Registry.LocalMachine; 
 6  RegistryKey key2 = key.OpenSubKey("SOFTWARE"); 
 7  RegistryKey key3 = key2.OpenSubKey("Microsoft"); 
 8  RegistryKey key4 = key3.OpenSubKey("Windows"); 
 9  RegistryKey key5 = key4.OpenSubKey("CurrentVersion"); 
10  RegistryKey key6 = key5.OpenSubKey("App Paths"); 
11  RegistryKey key7 = key6.OpenSubKey("Winword.exe"); 
12  return key7.GetValue("Path").ToString() + "WINWORD.EXE"
13}
 


Word保存在注册表中的路径为:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe.
同理 根据此方法可以得到其他软件的安装信息,如路径 版本号等。

posted on 2008-08-16 11:31  _张超  阅读(924)  评论(0)    收藏  举报

导航