private void btnGetOfficePath_Click(object sender, EventArgs e) { string officePath = ""; string officeVersion = ""; try { OfficeOperator.GetOfficePath(out officePath, out officeVersion); } catch (Exception ex) { MessageBox.Show("无法获取系统Office信息"); } if (!string.IsNullOrEmpty(officePath) && !string.IsNullOrEmpty(officeVersion)) { MessageBox.Show(string.Format("版本:{0}\r\n安装路径:{1}", officeVersion, officePath)); } }
//是否安装及版本 private void btnIsInstall_Click(object sender, EventArgs e) { try { string version = ""; if (OfficeOperator.IsInstall(out version)) { MessageBox.Show(string.Format("当前安装了{0}", version)); } else { MessageBox.Show("您当前还没有安装微软Office系列软件"); } } catch (Exception ex) { MessageBox.Show("无法获取系统Office信息"); } }