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 ...
随机推荐
- HDOJ/HDU 1251 统计难题(字典树啥的~Map水过)
Problem Description Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己 ...
- OpenCL memory object 之 Global memory (2)
转载自:http://www.cnblogs.com/mikewolf2002/archive/2011/12/18/2291584.html 当我们用clCreateBuffer, clCreate ...
- hdoj 1068 Girls and Boys【匈牙利算法+最大独立集】
Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- indexOf()不区分大小写用法
str.toLowerCase().indexOf(str.toLowerCase())>=0; 对字符串进行统一小写转换. indexOf()查找到返回索引值大于=0; 未找到,返回-1; i ...
- CodeIgniter开发实际案例-新闻网站【转】
CodeIgniter开发实际案例-新闻网站 转:http://blog.csdn.net/ict2014/article/details/22104711?utm_source=tuicool&am ...
- linux系统下安装apache与tomcat
apache的安装 把安装包放到/soft 下 [root@localhost ~]#cd /soft [root@localhost soft]#tar jxvf httpd-2.2.25.tar. ...
- Ajax-$.ajax()方法详解
jquery中的ajax方法参数总是记不住,这里记录一下. 1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(p ...
- JavaScript中七种函数调用方式及对应 this 的含义
this 在 JavaScript 开发中占有相当重要的地位,不过很多人对this这个东西都感觉到琢磨不透.要真正理解JavaScript的函数机制,就非常有必要搞清楚this到底是怎么回事. 函数调 ...
- android 70 使用ListView把数据显示至屏幕
使用单元测试添加数据: package com.itheima.showdata; import java.sql.ResultSet; import android.content.Context; ...
- Win32下 Qt与Lua交互使用:配置Qt下Lua运行环境
Lua与C++之间可以实现非常强的交互性.Lua中可以使用C++中的函数,C++中也可以使用Lua中的函数.由此可以引发出很多奇思妙想了. 简单来说,Lua动态的特性补充了C++的功能.当然,也看你具 ...