在程序启动时测试Office版本。 [英] Test for Office edition at program start.
本文介绍了在程序启动时测试Office版本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好。
我正在计划一个小项目。
我看到C#程序可以测试Office版本(即12,14,15)但我找不到任何信息,如果它可以测试版本(即Home和buissnes,家庭和学生,Pro)。
I am planing a little project.
I have seen that a C# program can test for Office version (ie. 12, 14, 15) but i can't find any info if it can test for the edition (ie Home and buissnes, home and student, Pro).
有没有办法测试一下?也许通过"链接"到注册表intery?
Is there a way to test this? Maybe by a "link" to the registry intery?
问候
Jonas
Regards
Jonas
推荐答案
这是一个样本。
Hi,
Here's a sample.
private void btn_GetOfficeVersion_Click(object sender, EventArgs e)
{
//
Type classType = Type.GetTypeFromProgID("Excel.Application");
object app = Activator.CreateInstance(classType);
if (app == null)
{
// not installed
}
// get version
object versionObj =
app.GetType().InvokeMember(
"Version", BindingFlags.GetProperty, null, app, null);
// set value to TextBox
txt_OfficeVersion.Text= versionObj.ToString();
}
<比照>
16:Office 2016
15:Office 2013
14:Office 2010
12:Office 2007
11:Office 2003
问候,
< cf. >
16: Office 2016
15: Office 2013
14: Office 2010
12: Office 2007
11: Office 2003
Regards,
这篇关于在程序启动时测试Office版本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文