C++判断Office版本——转载
自:http://blog.csdn.net/lpc_china/article/details/18359145
主要原理:查询windows注册表microsoft office软件项的值来判断版本。
主要源码:
头文件:
#pragma once
#include <Windows.h>
#include <tchar.h> class CJudgeOfficeVersion
{
public:
CJudgeOfficeVersion();
~CJudgeOfficeVersion(); public:
BOOL JudgeVersion(OUT LPTSTR _lpVersion, IN DWORD _dwVersionBufferLen);
};
源码:
#include "JudgeOfficeVersion.h"
#include <strsafe.h> /*
* 函数名称:CJudgeOfficeVersion
* 函数功能:构造函数
* 函数参数:无
* 函数返回:无
* 函数备注:无
* 编 写 人:刘鹏春
*/
CJudgeOfficeVersion::CJudgeOfficeVersion()
{ } /*
* 函数名称:~CJudgeOfficeVersion
* 函数功能:析构函数
* 函数参数:无
* 函数返回:无
* 函数备注:无
* 编 写 人:刘鹏春
*/
CJudgeOfficeVersion::~CJudgeOfficeVersion()
{ } /*
* 函数名称:JudgeVersion
* 函数功能:判断版本
* 函数参数:1字符指针;2指针长度;
* 函数返回:判断状态
* 函数备注:通过ProgID查找CLSID查询服务器中记录的Office版本信息
* 该代码源自:http://support.microsoft.com/kb/247985/zh-cn
* 编 写 人:刘鹏春
*/
BOOL CJudgeOfficeVersion::JudgeVersion(OUT LPTSTR _lpVersion, IN DWORD _dwVersionBufferLen)
{
HKEY hKey;
HKEY hSubKey;
LONG lResult = 0L; TCHAR szValueName[] = {_T("CurVer")};
TCHAR szKey[] = {_T("Excel.Application")}; lResult = RegOpenKeyEx(
HKEY_CLASSES_ROOT,
szKey,
,
KEY_ALL_ACCESS,
&hKey
);
if (ERROR_SUCCESS != lResult) {
MessageBox(NULL, _T("Could not get CLSID from ProgID, Make sure ProgID is correct."), _T("提示"), MB_OK);
return FALSE;
} lResult = RegOpenKeyEx(
hKey,
szValueName,
,
KEY_ALL_ACCESS,
&hSubKey
);
if (ERROR_SUCCESS != lResult) {
MessageBox(NULL, _T("Excel is registered, but no local server can be found!"), _T("提示"), MB_OK);
return FALSE;
} lResult = RegQueryValueEx(hSubKey, NULL, NULL, NULL, (LPBYTE)_lpVersion, &_dwVersionBufferLen); RegCloseKey(hSubKey);
RegCloseKey(hKey); if (ERROR_SUCCESS != lResult) {
return FALSE;
} PTCHAR pszVersionNumber = _tcsrchr(_lpVersion, _T('.'));
PTCHAR pVersion = (pszVersionNumber + );
INT nVersion = _ttoi(pVersion); ZeroMemory(_lpVersion, _dwVersionBufferLen);
switch (nVersion)
{
case :
case :
case :
case :
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 95以前版本"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 95"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 97"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 2000"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office XP"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 2003"));
break;
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 2007"));
break;
case :
case :
case :
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Office 2010"));
break;
default:
StringCchCopy(_lpVersion, _dwVersionBufferLen, _T("Version 2010以后版本"));
} return TRUE;
}
*注:此方法还是比较简答而且容易是实现的。
C++判断Office版本——转载的更多相关文章
- 获取Windows平台下 安装office 版本位数信息
最近在处理客户端安装程序过程,有一个需求:需要检测Windows平台下安装office 版本信息以及获取使用的office是32 位还是64 位: 当检测出office 位数为64位时,提示当前off ...
- powershell 判断操作系统版本 命令
powershell 传教士 原创文章.始于 2015-12-15 允许转载,但必须保留名字和出处,否则追究法律责任 一 前言 判断操作系统版本,是个老话题,bat.vbs中都有例子,这本不是重要问题 ...
- 如何判断Office是32位还是64位?
对于持续学习VBA的老铁们,有必要了解Office的位数. 如果系统是32位的,则不需要判断Office位数了,因为只能安装32位Office. 下面只讨论64位系统中,Office的位数判断问题. ...
- HMTL判断ie版本
html判断IE版本 1. <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> 2. <!--[if IE]> ...
- js实现判断浏览器版本
//判断浏览器版本是否过低 var ua = navigator.userAgent.toLowerCase(); if (window.ActiveXObject) var IEversion = ...
- Office版本差别引发的语法问题
由于没有源代码,今天反编译了一个基于.NET的dll类库,再次遇到office版本差异问题,所以把它记录下来. 在反编译时,需要Aspose.Cells 5.3.1(Aspose是一套.NET类库,其 ...
- vc 取windows系统信息 版本 cpu信息 内存信息 ie版本信息 office版本
头文件: /*! Copyright (C) *---------------------------------------------------------------------------- ...
- html判断IE版本
html判断IE版本 . <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> . <!--[if IE]> ...
- jquery判断浏览器版本插件,jquery-browser.js
jquery判断浏览器版本插件,jquery-browser.js,jquery 判断是否为ie浏览器插件 >>>>>>>>>>>&g ...
随机推荐
- HTML5 application cache
Application Cache API (一) 基本应用 http://www.cnblogs.com/blackbird/archive/2012/06/12/2546751.html Appl ...
- show drop down menu within/from action bar
show drop down menu within/from action bar */--> pre { background-color: #2f4f4f;line-height: 1.6 ...
- 蔡勒(Zeller)公式
蔡勒(Zeller)公式,是一个计算星期的公式,随便给一个日期,就能用这个公式推算出是星期几. W =[ [c/4] - 2c + y + [y/4] + [13 * (m+1) / 5] + d - ...
- 【转】[慢查优化]联表查询注意谁是驱动表 & 你搞不清楚谁join谁更好时请放手让mysql自行判定
转自:http://zhengyun-ustc.iteye.com/blog/1942797 写在前面的话: 不要求每个人一定理解 联表查询(join/left join/inner join等)时的 ...
- Binggo公开课 “CODEX创新体系”的实战演练-中关村创业大街
Binggo公开课 "CODEX创新体系"的实战演练-中关村创业大街 Binggo公开课 "CODEX创新体系"的实战演练
- Spark history-server 配置 !运维人员的强大工具
spark history Server产生背景 以standalone运行模式为例,在运行Spark Application的时候,Spark会提供一个WEBUI列出应用程序的运行时信息:但该WE ...
- hdoj 3952 World Exhibition
World Exhibition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 【转】PyDev for Eclipse 简介
转自:http://www.ibm.com/developerworks/cn/opensource/os-cn-ecl-pydev/index.html PyDev for Eclipse 是一 ...
- 用高德地图API 通过详细地址获得经纬度
http://cloud.sinyway.com/Service/amap.html http://restapi.amap.com/v3/geocode/geo?key=xxxxxxxxxxxxxx ...
- CFileDialog的使用方法简单介绍
CFileDialog文件选择对话框的使用:首先构造一个对象并提供对应的參数,构造函数原型例如以下: CFileDialog::CFileDialog( BOOL bOpenFileDialog, L ...