网站首页
网站导航
Ctrl+D收藏
首 页
代码段
源码包
文档库
工具箱
代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
通过注册表检测是否安装Office和QQ等软件
作者:
Dezai.CN
/ 发布于
2013/4/22
/
1983
检测Office是否安装以及获取安装 路径 及安装版本
#region 检测Office是否安装 ///<summary> /// 检测是否安装office ///</summary> ///<param name="office_Version"> 获得并返回安装的office版本</param> ///<returns></returns> public static bool IsInstallOffice(out string office_Version, out string office_Path) { bool result = false; string str_OfficePath = string.Empty; string str_OfficeVersion = string.Empty; office_Version = string.Empty; office_Path = string.Empty; GetOfficePath(out str_OfficePath, out str_OfficeVersion); if (!string.IsNullOrEmpty(str_OfficePath) && !string.IsNullOrEmpty(str_OfficeVersion)) { result = true; office_Version = str_OfficeVersion; office_Path = str_OfficePath; } return result; } ///<summary> /// 获取并返回当前安装的office版本和安装路径 ///</summary> ///<param name="str_OfficePath">office的安装路径</param> ///<param name="str_OfficeVersion">office的安装版本</param> private static void GetOfficePath(out string str_OfficePath, out string str_OfficeVersion) { string str_PatheResult = string.Empty; string str_VersionResult = string.Empty; string str_KeyName = "Path"; object objResult = null; Microsoft.Win32.RegistryValueKind regValueKind;//指定在注册表中存储值时所用的数据类型,或标识注册表中某个值的数据类型。 Microsoft.Win32.RegistryKey regKey = null;//表示 Windows 注册表中的项级节点(注册表对象?) Microsoft.Win32.RegistryKey regSubKey = null; try { regKey = Microsoft.Win32.Registry.LocalMachine;//读取HKEY_LOCAL_MACHINE项 if (regSubKey == null) {//office97 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\8.0\Common\InstallRoot", false);//如果bool值为true则对打开的项进行读写操作,否则为只读打开 str_VersionResult = "Office97"; str_KeyName = "OfficeBin"; } if (regSubKey == null) {//Office2000 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\9.0\Common\InstallRoot", false); str_VersionResult = "Pffice2000"; str_KeyName = "Path"; } if (regSubKey == null) {//officeXp regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\10.0\Common\InstallRoot", false); str_VersionResult = "OfficeXP"; str_KeyName = "Path"; } if (regSubKey == null) {//Office2003 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\11.0\Common\InstallRoot", false); str_VersionResult = "Office2003"; str_KeyName = "Path"; try { objResult = regSubKey.GetValue(str_KeyName); regValueKind = regSubKey.GetValueKind(str_KeyName); } catch (Exception ex) { regSubKey = null; } } if (regSubKey == null) {//office2007 regSubKey = regKey.OpenSubKey(@"SOFTWARE\Microsoft\Office\12.0\Common\InstallRoot", false); str_VersionResult = "Office2007"; str_KeyName = "Path"; } objResult = regSubKey.GetValue(str_KeyName); regValueKind = regSubKey.GetValueKind(str_KeyName); if (regValueKind == Microsoft.Win32.RegistryValueKind.String) { str_PatheResult = objResult.ToString(); } } catch (Exception ex) { LogHelper.WriteLogError(ex.ToString()); //throw ex; } finally { if (regKey != null) { regKey.Close(); regKey = null; } if (regSubKey != null) { regSubKey.Close(); regSubKey = null; } } str_OfficePath = str_PatheResult; str_OfficeVersion = str_VersionResult; } #endregion 同理,检测QQ、Fetion、360杀毒、IE浏览器,Chrome、Office 2003/2007/2010 只需修改验证: regSubKey = regKey.OpenSubKey(@"SOFTWARE\Tencent\PlatForm_Type_List\3", false);//如果bool值为true则对打开的项进行读写操作,否则为只读打开 即可 检测QQ是否已安装,通过注册表
评论列表
本站所提供的代码,版权归原作者所有,若有侵犯作者版权,请与我们联系,我们将立即删除或修改。谢谢!
本站所有代码发布及提供者。
试试其它关键字
检测是否安装Offic
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
.
实现对图片上传的接收
.
判断用户输入的是否为IP地址
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
地图
本站
我们
服务
版权
联系
回馈
博客