判断 本机安装 office 版本
文章转自王牌软件
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
只回答业务咨询
站长推荐:NSetup一键部署软件
一键式完成美化安装包制作,自动增量升级,数据统计,数字签名。应对各种复杂场景,脚本模块化拆分,常规复杂的脚本代码,图形化设置。无需专业的研发经验,轻松完成项目部署。(www.nsetup.cn)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
#include "msword.h" HRESULT AutoWrap(int autoType, VARIANT *pvResult, IDispatch *pDisp, LPOLESTR ptName, int cArgs...) { // Begin variable-argument list va_list marker; va_start(marker, cArgs); if (!pDisp) { _putws(L"NULL IDispatch passed to AutoWrap()"); _exit(0); return E_INVALIDARG; } // Variables used DISPPARAMS dp = { NULL, NULL, 0, 0 }; DISPID dispidNamed = DISPID_PROPERTYPUT; DISPID dispID; HRESULT hr; // Get DISPID for name passed hr = pDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID); if (FAILED(hr)) { wprintf(L"IDispatch::GetIDsOfNames(\"%s\") failed w/err 0x%08lx\n", ptName, hr); _exit(0); return hr; } // Allocate memory for arguments VARIANT *pArgs = new VARIANT[cArgs + 1]; // Extract arguments... for(int i=0; i < cArgs; i++) { pArgs[i] = va_arg(marker, VARIANT); } // Build DISPPARAMS dp.cArgs = cArgs; dp.rgvarg = pArgs; // Handle special-case for property-puts if (autoType & DISPATCH_PROPERTYPUT) { dp.cNamedArgs = 1; dp.rgdispidNamedArgs = &dispidNamed; } // Make the call hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL); if (FAILED(hr)) { wprintf(L"IDispatch::Invoke(\"%s\"=%08lx) failed w/err 0x%08lx\n", ptName, dispID, hr); _exit(0); return hr; } // End variable-argument section va_end(marker); delete[] pArgs; return hr; } void Cwps_msword2013Dlg::OnBnClickedButton1() { CString strAppName = OLESTR("word.application"); bool bResult = false; IDispatch * wordApp; CLSID appClsid; if(S_OK == CLSIDFromProgID(strAppName, &appClsid)) { if(S_OK == CoCreateInstance(appClsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void **)&wordApp)) { Word::_Application appWord; if(S_OK == wordApp->QueryInterface(IID_IDispatch, (void**)&appWord)) { CString strVersion = _T(""); strVersion = appWord.GetVersion(); if(_ttoi(strVersion) >= 15.0) { bResult = true; } } } AutoWrap(DISPATCH_METHOD, NULL, wordApp, L"Quit", 0); wordApp->Release(); } if(bResult) MessageBox(_T("ok"), _T("tip")); else MessageBox(_T("no"), _T("tip")); //return bResult; } |
学习日记,兼职软件设计,软件修改,毕业设计。
本文出自 学习日记,转载时请注明出处及相应链接。
本文永久链接: https://www.softwareace.cn/?p=701