1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/appcore/RCS/appcore.cpp $
4 // $Date: 1997/02/15 17:44:44 $
20 ///////////////////////////////////////////////////////////////////////////////
22 static IAggregate
* pAppAggregate
;
24 ///////////////////////////////////////////////////////////////////////////////
26 tResult
_AppAggregateCreate(REFIID
)
28 pAppAggregate
= CreateGenericAggregate("Application Aggregate", kISetKeyLGGUIDs
);
29 AssertMsg(pAppAggregate
, "Failed to create application aggregate!");
30 _AppSetAggregate(pAppAggregate
);
31 return (pAppAggregate
) ? NOERROR
: E_FAIL
;
34 ///////////////////////////////////////
36 static BOOL g_fCallAppExit
;
37 static BOOL g_fReturnedFromMain
;
41 // Tell the app the components are about to go away
49 // This module always retains 1 reference on the aggregate. However, this
50 // function must handle the (not too unusual) case of closing without cleaning
51 // up all reference counts.
53 ulong ulRefsRemaining
= pAppAggregate
->ReleaseAll();
54 //AssertMsg1(!g_fReturnedFromMain || ulRefsRemaining == 1, "Reference of application object is incorrect on exit (was %d, expected 1)", ulRefsRemaining);
59 ///////////////////////////////////////////////////////////////////////////////
63 int _g_referenceExtendedStartup
= 0;
64 extern int _g_referenceEntryPoint
;
68 ///////////////////////////////////////////////////////////////////////////////
70 // This is the primary client entry-point
74 int LGAPI
_AppMain(int argc
, const char *argv
[])
76 // Force link of main/WinMain/LibMain
77 _g_referenceEntryPoint
= 1;
80 // Allow our code to be self-modifying
81 if (GetPrivateProfileInt("AppCore", "MakeAllCodeWritable", !!(g_fAppStartupFlags
& kASF_MakeCodeWritable
), "lg.ini"))
82 MakeAllCodeWritable();
85 // Increase the number of available handles in the standard buffered i/o
89 #pragma message("Need a way to increase available file handles")
92 // Create the core aggregate entity
93 _AppAggregateCreate(IID_IAggregate
);
95 // Tell the app to create the application-level COM objects
96 if (AppCreateObjects(argc
, argv
) != NOERROR
)
99 // Clean-up is done through exit()
102 // Initialize the components
104 pAppAggregate
->Init();
106 // Tell the app the components are initialized
107 if (AppInit() != NOERROR
)
110 // Set flag indicating successful initialization, so should call AppExit()
111 g_fCallAppExit
= TRUE
;
113 // Start the application
114 int mainRetVal
= AppMain(argc
, argv
);
115 g_fReturnedFromMain
= TRUE
;
119 ///////////////////////////////////////////////////////////////////////////////
121 // Symbol to Force inclusion of this extended startup code
124 int __ExtendedStartup(void)