对于 对象映射列表的每选件类,此函数调用,当初始化模块时,然后再次时,会将停止。
语法
      static void WINAPI ObjectMain(
   bool bStarting 
);
参数
- bStarting
[in]该值为 true,如果选件类初始化;否则 false。 
备注
bStarting 参数的值指示模块是否已初始化或停止。ObjectMain 的默认实现不执行任何操作,但是,您可以重写在您的选件类中调用此函数初始化和清理要用于选件类已分配的资源。请注意 ObjectMain 调用,在选件类的所有实例请求之前。
ObjectMain 从调用入口点DLL,因此入口点函数可以执行受限制的类型操作。有关这些限制的更多信息,请参见 运行库行为 和 DllMain。
class ATL_NO_VTABLE CMyApp :
   public CComObjectRootEx<CComSingleThreadModel>,
   public CComCoClass<CMyApp, &CLSID_MyApp>,
   public IMyApp
{
public:
   CMyApp()
   {
   }
   static void WINAPI ObjectMain(bool bStarting)
   {
      if (bStarting)
         ;// Perform custom initialization routines
      else
         ;// Perform custom termination routines
   }
   // Remainder of class declaration omitted.
要求
Header: atlcom.h