|
发表于 2004-10-6 21:51:00
|
显示全部楼层
确实,我是想做打包程序,但是没办法用COM实现,后来想了一个别的办法,尽管有点复杂,但是也是一种解决方法,我把代码贴出来,希望对大家有借鉴作用: BOOL CFCCHApp::InitInstance()
{
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
CString arxPath;
arxPath=this->m_pszHelpFilePath; /*关键是这里,我找不出别的函数来得到EXE程序的路径,所以就用这个函数来得到帮助文件的路径,实际上,帮助文件没有,但是路径有用,所以,把帮助文件名减掉,就可以得到EXE文件的路径,这样的话,就可以不设置支持路径了*/
arxPath=arxPath.Left(arxPath.GetLength()-8);
IAcadApplication IAcadApp;
// IAcadPreferencesFiles IAcadPreFiles;
IAcadMenuGroup *pMenu;
BOOL bRet = IAcadApp.CreateDispatch(_T("AutoCAD.Application"));
if(bRet)
{
IAcadApp.SetVisible(TRUE);
IAcadApp.LoadArx(arxPath+"cugsetcadtitle.arx");
IAcadApp.LoadDVB(arxPath+"dvb\\XM_0000MenuSelect.dvb");
IAcadApp.LoadDVB(arxPath+"dvb\\FQ_0000MenuSelect.dvb");
}
else
{
AfxMessageBox("没有正确安装AutoCAD 2002,\r\n请核对后运行",MB_ICONERROR | MB_OK);
return FALSE;
}
return FALSE;
}
另外,我上面可以在CAD启动的时候自动加载ARX和VBA,但是我到现在也没找出来,如何利用COM来实现自动加载自定义的菜单,各位指点指点 |
|