下面实现了应用程序加载和卸载时用到的函数。其中初始化的过程中向AutoCAD中注册了两个新命令:CREATE 和ITERATE。他同时初始化了一个自定义类AsdkMyClass并且通过调用acrxBuildClassHierarchy()函数将他添加到运行时类的结构当中。(关于AsdkMyClass 的描述,一个自定义类的例子参考第12.6节)
// The initialization function called from the acrxEntryPoint()
// function during the kInitAppMsg case is used to add commands
// to the command stack and to add classes to the ACRX class
// hierarchy.
//
void
initApp()
{
acedRegCmds->addCommand("ASDK_DICTIONARY_COMMANDS",//组名
"ASDK_CREATE", "CREATE", ACRX_CMD_MODAL,//命令名,命令名,命令类型
createDictionary);//命令对应的函数
acedRegCmds->addCommand("ASDK_DICTIONARY_COMMANDS",
"ASDK_ITERATE", "ITERATE", ACRX_CMD_MODAL,
iterateDictionary);
AsdkMyClass::rxInit();//自定义类的初始化
acrxBuildClassHierarchy();//新加类添加到运行时类结构中
}
// The cleanup function called from the acrxEntryPoint()
// function during the kUnloadAppMsg case removes this application's
// command set from the command stack and removes this application's
// custom classes from the ACRX runtime class hierarchy.
//
void
unloadApp()
{
acedRegCmds->removeGroup("ASDK_DICTIONARY_COMMANDS");//移除命令组
// Remove the AsdkMyClass class from the ACRX runtime
// class hierarchy. If this is done while the database is
// still active, it should cause all objects of class
// AsdkMyClass to be turned into proxies.
//
deleteAcRxClass(AsdkMyClass::desc());//自定义类移除
}