问题描述:
有不少客户在实际开发过程中会涉及同时开发多个中望CAD版本,因为有不同版本之间的区别需要做差异化,需要获取当前版本信息,如想知道当前版本是2021,2023还是2025。
目前标准接口返回的值不准确,可以使用下面方法:
步骤指引:
C++代码:
#include <acadi.h>
#include "acadi_i.c"
#include "aced.h"
void helloworld()
{
::CoInitialize(NULL);
IAcadApplication *pAcad;
HRESULT hr = NOERROR;
LPUNKNOWN pUnk = NULL;
LPDISPATCH pAcadDisp = acedGetIDispatch(TRUE);
hr = pAcadDisp->QueryInterface(IID_IAcadApplication, (void**)&pAcad);
pAcadDisp->Release();
if (FAILED(hr))
return;
BSTR str;
pAcad->get_Version(&str);
acutPrintf(_T("\nHello world!"));
}
C#代码:PS:需要应用com组件,可以直接应用安装目录下zwcad.exe
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZwSoft.ZwCAD.Runtime;
using ZwSoft.ZwCAD.ApplicationServices;
using ZwSoft.ZwCAD.Geometry;
using ZwSoft.ZwCAD.DatabaseServices;
using ZwSoft.ZwCAD.EditorInput;
using ZWCAD;
[assembly: CommandClass(typeof(ZrxDotNetCSProject173.Commands))]
namespace ZrxDotNetCSProject173
{
class Commands
{
[CommandMethod("getVersion")]
public static void pzdm()
{
ZWCAD.ZcadApplication zwcad = (ZWCAD.ZcadApplication)ZwSoft.ZwCAD.ApplicationServices.Application.ZcadApplication;
string strVersion = zwcad.Version;
}
}
}
| 英文空间链接 |
|---|
★中望CAD二次开发中如何获取版本号?:https://confluence.zwcad.com/pages/viewpage.action?pageId=293143641