检测Office是否安装以及获取安装 路径 及安装版本 QQ,迅雷,旺旺 C#代码
#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是否已安装,通过注册表
#region 检测QQ是否安装
public static bool isInstallQQ(out string QQVersion, out string QQPath)
{
bool result = false;
string str_QQPath = string.Empty;
string str_QQVersion = string.Empty;
QQVersion = string.Empty;
QQPath = string.Empty; GetQQPath(out str_QQPath, out str_QQVersion);
if (!string.IsNullOrEmpty(str_QQPath) && !string.IsNullOrEmpty(str_QQVersion))
{
result = true;
QQVersion = str_QQVersion;
QQPath = str_QQPath;
}
return result;
} /// <summary>
///
/// </summary>
/// <param name="str_QQPath"></param>
/// <param name="str_QQVersion"></param>
private static void GetQQPath(out string str_QQPath, out string str_QQVersion)
{
string str_PatheResult = string.Empty;
string str_VersionResult = string.Empty;
string str_KeyName = "TypePath";
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)
regSubKey = regKey.OpenSubKey(@"SOFTWARE\Tencent\PlatForm_Type_List\3", false);//如果bool值为true则对打开的项进行读写操作,否则为只读打开
str_VersionResult = "QQ";
str_KeyName = "TypePath";
}
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_QQPath = str_PatheResult;
str_QQVersion = str_VersionResult;
}
#endregion
迅雷
#region 检测 Thunder 迅雷
public static bool isInstallThunder(out string thunderVersion, out string thunderPath)
{
bool result = false;
string str_ThunderPath = string.Empty;
string str_ThunderVersion = string.Empty;
thunderVersion = string.Empty;
thunderPath = string.Empty;
// veryhuo.com
GetThunderPath(out str_ThunderPath, out str_ThunderVersion);
if (!string.IsNullOrEmpty(str_ThunderPath) && !string.IsNullOrEmpty(str_ThunderVersion))
{
result = true;
thunderVersion = str_ThunderVersion;
thunderPath = str_ThunderPath;
}
return result;
} /// <summary>
///
/// </summary>
/// <param name="str_QQPath"></param>
/// <param name="str_QQVersion"></param>
private static void GetThunderPath(out string str_thunderPath, out string str_thunderVersion)
{
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)
regSubKey = regKey.OpenSubKey(@"SOFTWARE\Thunder Network\ThunderOem\thunder_backwnd", false);//如果bool值为true则对打开的项进行读写操作,否则为只读打开
str_VersionResult = "Thunder";
str_KeyName = "Path";
}
objResult = regSubKey.GetValue(str_KeyName);
regValueKind = regSubKey.GetValueKind(str_KeyName);
if (regValueKind == Microsoft.Win32.RegistryValueKind.ExpandString)
{
str_PatheResult = objResult.ToString();
}
}
catch (Exception ex)
{
LogHelper.WriteLogError(ex.ToString());
}
finally
{
if (regKey != null)
{
regKey.Close();
regKey = null;
}
if (regSubKey != null)
{
regSubKey.Close();
regSubKey = null;
}
}
str_thunderPath = str_PatheResult;
str_thunderVersion = str_VersionResult;
}
#endregion
检测Office是否安装以及获取安装 路径 及安装版本 QQ,迅雷,旺旺 C#代码的更多相关文章
- Javascript中获取浏览器类型和操作系统版本等客户端信息常用代码
/** * @author hechen */ var gs = { /**获得屏幕宽度**/ ScreenWidth: function () { return window.screen.widt ...
- 获取Windows平台下 安装office 版本位数信息
最近在处理客户端安装程序过程,有一个需求:需要检测Windows平台下安装office 版本信息以及获取使用的office是32 位还是64 位: 当检测出office 位数为64位时,提示当前off ...
- Visual Studio安装项目中将用户选择的安装路径写入注册表的方法[转]
在你的工程名上右击 -> View ->Registry(视图 -> 注册表) 在你需要写注册表的主键下,例如我注册firefox插件的例子是: (1)右击HKEY_CURRENT_ ...
- c# 遍历所有安装程序 获取所有已经安装的程序
/// <summary> /// 获取所有已经安装的程序 /// </summary> /// <param name="reg"></ ...
- 如何安装 Microsoft Office 兼容包,以便您可以在早期版本的 Microsoft Office 中打开和保存 Office Open XML 格式
https://support.microsoft.com/zh-cn/kb/923505 针对 Office 2003 的支持已终止 Microsoft 已于 2014 年 4 月 8 日终止了针对 ...
- 在linux下面安装mysql 确认 配置文件路径 my.cnf
1.确认服务器my.cnf 文件路径.但不知道那个是 2.通过which mysql命令来查看mysql的安装位置: 3.通过/usr/local/mysql/bin/mysqld --verbose ...
- rpm2cpio---如何不安装但是获取rpm包中的文件
如何不安装但是获取rpm包中的文件 使用工具rpm2cpio和cpio rpm2cpio xxx.rpm | cpio -idmv 参数i表示提取文件.v表示指示执行进程,d和make-directo ...
- python获取本机的安装所有应用( Windows)
Windows获取本机的安装所有应用 采用操作注册表的方式,理论上其他可通过操作注册表方式的动作均可 import winreg def get_window_software(hive, flag) ...
- SQL Server 2008 修改安装路径后安装出错的解决方法
1.安装时如果修改安装路径后报错 例如想把“C:\Program Files\Microsoft SQL Server” 修改为“D:\Program Files\Microsoft SQL Serv ...
随机推荐
- c#泛型方法重载
这里存在普通的方法Foo和泛型方法Foo,如果直接调用: 则会自动优先匹配对应的非泛型方法.输出如下: 但需要注意的是,这一匹配过程是在编译过程进行的,所以如果是通过其它泛型间接调用.则只会调用对应的 ...
- 写漂亮C#代码的小技巧
第一次写博客,不知道代码用什么编辑,直接截图了,哈哈哈.... 我自己不喜欢看随便复制粘贴过来一堆代码的博客,所以,用些简单点的例子吧,希望对大家有帮助... ------------------- ...
- Mysql JDBC 连接串参数说明
MySQL的 JDBC URL 格式 for Connector/J 如下例: jdbc:mysql://[host:port],[host:port].../[database][?参数名1][= ...
- 【培训】交换机VLAN
为了解决用交换机做LAN互联无法限制广播的问题,出现了VLAN技术,把一个LAN划分为多个逻辑的“LAN”-VLAN. VLAN技术将一个物理的LAN逻辑地划分为不同的广播域,每一个VLAN包含一组有 ...
- OpenGl入门——视口及物体移动函数
大学的时候有个选修课,要用OpenGl,很初级的内容,同样入门的学弟学妹适用 推荐个学习的资料NeHe的OpenGl教程,很完整而且有示例,讲的很明白.比某些破书好. 可以配合那本所谓的“红宝书”看看 ...
- SGU 280.Trade centers(贪心)
SGU 280.Trade centers 解题报告 题意: n(<=30000)个城市,(n-1)条道路,求最少需要选择多少个城市建造市场,使得所有城市到任意一个市场的距离不大于k. Solu ...
- java.util.HashMap源码分析
在java jdk8中对HashMap的源码进行了优化,在jdk7中,HashMap处理“碰撞”的时候,都是采用链表来存储,当碰撞的结点很多时,查询时间是O(n). 在jdk8中,HashMap处理“ ...
- 挂载磁盘的问题(/dev/sdb1 is apparently in use by the system; will not make a 文件系统 here!)
用fdisk给新磁盘分区后.然后要创建文件系统 [root@cuizhipeng ~]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)/dev/sdb ...
- SQLite学习第01天:参考资料
今天开始学习数据库相关的知识,由于本人从事的是嵌入式软件开发方向,所以在数据库的选择时就果断选择了SQLite,在网上搜索了一下相关的资料并且配置好了环境.首先,想要对SQLite有一个基本的了解还是 ...
- How to say all the keyboard symbols in English and Chinese
How to say all the keyboard symbols in English Symbol English 中文 ~ tilde 波浪号 ` grave accent, backquo ...