一个使用ActiveX自动化技术读写DWG文件的程序
斑竹,请救!在VC环境下我用OLE自动化技术来读写AutoCAD的DWG文件,我完全按照别人文章的程序建立程序,但是出现AutoCAD无法启动的错误.请问这是什么原因?<BR>其读写DWG文件的函数如下:<BR><BR>void CAcadRWDwgDoc::OnRwDwg() <BR>{<BR> // TODO: Add your command handler code here<BR> VARIANT startPoint,endPoint;<BR> SAFEARRAY* start = NULL;<BR> SAFEARRAY* end = NULL;<BR> IAcadApplication acad;<BR><BR> COleVariant covTrue((short)TRUE),<BR> covFalse((short)FALSE),<BR> covOne((long)0),<BR> covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);<BR> //启动Autocad应用软件<BR><BR> if(!acad.CreateDispatch("AutoCAD.Application.15"))<BR> {<BR> AfxMessageBox("Autocad 启动失败"); <BR> return;<BR> }<BR> acad.SetVisible(TRUE);<BR> IAcadDocuments docs = acad.GetDocuments();<BR> long total = docs.GetCount();<BR> IAcadDocument doc = docs.Open("C:\\Documents and Settings\\Administrator\\MyDocuments\\Drawing1",covFalse); <BR><BR> IAcadModelSpace mSpace = doc.GetModelSpace();<BR> long entitiesNum = mSpace.GetCount();<BR><BR> if(entitiesNum >= 1)<BR> {<BR> IAcadEntity entity = mSpace.Item(covOne);<BR> CString name = entity.GetObjectName();<BR><BR> if(name == "AcDbLine"){<BR> IAcadLine line = mSpace.Item(covOne);<BR> startPoint = line.GetStartPoint();<BR> endPoint = line.GetEndPoint();<BR> }<BR> }<BR> start = PointToSafeArrayB(1,1,0);<BR> startPoint.vt = VT_R8|VT_ARRAY;<BR> startPoint.parray = start;<BR> end = PointToSafeArrayA(100,200,0);<BR> endPoint.vt = VT_R8|VT_ARRAY;<BR> endPoint.parray = end;<BR> mSpace.AddLine(startPoint,endPoint);<BR> mSpace.AddCircle(endPoint,60);<BR> mSpace.AddText("I LOVE YOU AUTOCAD",endPoint,100);<BR> SafeArrayDestroy(start);<BR> SafeArrayDestroy(end);<BR><BR> COleVariant name("C:\\Documents and Settings\\Administrator\\My Documents\\Drawing1");<BR> doc.Close(covTrue,name);<BR> acad.Quit();<BR> <BR>}其中当程序执行到<BR>if(!acad.CreateDispatch("AutoCAD.Application.15"))<BR> {<BR> AfxMessageBox("Autocad 启动失败"); <BR> return;<BR> }<BR>这里时,编译指出不能找到指定的文件,另外,在注册表HKEY_CLASSES_ROOT中里找不到AutoCAD<BR>组件的DLL文件名称。我想AutoCAD无法启动可能跟这个有关系?<BR>
页:
[1]