[This is preliminary documentation and subject to change.]
A loader is a dynamic-link library (DLL) that can be called by Loadstub.exe, a component that starts loader applications. The prototype for an entry-point function for a loader is:
ExitCodeList APIENTRY
EPG_DBLoad(int &argc, _TCHAR **argv, CdbDBEngine &db
, PFNFORCEQUIT pfnForceQuit);
The mechanism for passing the specific information that a loader requires is to include the information as command-line arguments to Loadstub.
Loadstub passes the command-line arguments that it does not handle itself to the entry-point function of a loader when that loader is called. These arguments are passed by means of the entry-point function's first two arguments, argc and argv. Any arguments your loader requires can be passed using these arguments. For example, Loadstub can pass the user's zip code to select the channels to load for a given region. For more information on Loadstub and its arguments, see Loadstub.
In addition to such loader-specific arguments, Loadstub can pass a /c argument to request that the loader compact the database, or a /p argument to request a partial database update. For more information on how to handle these arguments, see Removing Records Using Special Functions.
Another command-line argument a user or setup application can specify is /L, which tells the loader about the source of the data. The format of this argument depends on the data source. For example, if the data comes from the Internet, the argument can be the Uniform Resource Locator (URL) of the data source.
The third argument for the entry-point function, db, is a reference to the DAO database engine. This value must be passed to any function that accesses the Guide database. To locate more information on the CdbDBEngine object used in this argument, see Further Information on Development Tasks in Broadcast Architecture. The sample loader saves the value in a member of the application object called m_pDAODB.
The last argument, pfnForceQuit, is a pointer to a function that returns a value that is TRUE if the operating system is trying to shut down the loader, and FALSE otherwise. Your loader should check this function from time to time to see if the loader should shut down. Doing so prevents the operating system from forcing the loader to exit without performing necessary cleanup operations, such as closing databases and releasing system resources.