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 ...
随机推荐
- How to compile pycrypto 2.4.1 (python 3.2.2 for Windows 7 x64)
How to compile pycrypto 2.4.1 (python 3.2.2 for Windows 7 x64) Nov 10 Posted by alesk This note is a ...
- gcc “-I”(大写i),“-L”(大写l),“-l”(小写l)的区别
我们用gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录: 例: gcc -o hello hello.c -I /home/hello/inc ...
- [LeetCode] Minimum Size Subarray Sum 解题思路
Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...
- [bzoj\lydsy\大视野在线测评]题解(持续更新)
目录: 一.DP 二.图论 1.最短路 2.强连通分量 三.利用单调性维护 四.贪心 五.数据结构 1.并查集 六.数学 1.计数问题 2.数学分析 七.博弈 八.搜索 /////////////// ...
- poj 3628 (搜索or背包)
好久没看背包题目了!!!生疏了!!!! 这题是背包题!!!不过对于这题,解决方法还是搜索省时!!! 题意:第一行给你一个N和VV,接下来N行,每行一个数,求得是任选N个数组合求和,求组合的和大于VV而 ...
- medoo数据库插入的问题
今天遇到疾行客同学提出的medoo insert方法不能插入数据库问题,我测试了一下 发现是可以的 而INSERT INTO "t_user" (username) VALUES ...
- js去除空格
function trim(str){ return str.replace(/(^\s*) | ( \s*$ )/g,"" ); }
- Find发帖水王哥
Find发帖水王 传说贴吧有一大“水王”,他不但喜欢发帖,还会回复其他ID发的每个帖子.坊间风闻该“水王”发帖数目超过了帖子总数的一半.如果你有一个当前论坛上所有帖子(包括回帖)的列表,其中帖子作者的 ...
- Android Butterknife框架配置
一.原理. 最近发现一个很好用的开源框架,蛮不错的,可以简化你的代码,是关于注解的.不多说直接进入使用步骤讲解. 二.步骤. 1.准备阶段,先到官网( http://jakewharton.githu ...
- Tomcat优化参数
JAVA_OPTS="-Xmx400m -Xms400m -XX:PermSize=128m -XX:MaxPermSize=400m -XX:+UseG1GC -XX:MaxGCPause ...