The Litgen.dll usage information is located in the descriptions in the .idl, and the overall flow is described in the interface description of ILITWriter.
Note the following exceptions:
Note: Since Litgen.dll uses COM components internally, you must call CoInitialize before ILITWriter::Create() even if you do not make any other calls to COM libraries.
In some situations, simply calling LoadLibrary("litgen.dll") would be sufficient. The extra work to construct a full path is required for more complex situations, such as when Litgen.dll is incorporated into a conventional COM inproc server. LoadLibrary() has a list of directories it searches for a named .dll. The directory from which the .exe itself is loaded is included in this list, but the directory from which some COM .dll was loaded is not. For these situations, you must tell LoadLibrary() where to look.
The component is typically installed with code like the following (error handling has been removed for brevity):
IUnknown* pUnkLitWriter = 0;
ILITWriter* pLitWriter = 0;
// we'll construct a complete pathname for litgen.dll
//into szLitgenFilename, which we declare
//large enough to hold the largest possible
//path, plus a null terminator
char szLitgenFilename[MAX_PATH+1];
HMODULE hLITGen;
typedef HRESULT (*WriterCreator)(IUnknown**);
WriterCreator CreateWriter;
// some of this can be elided for clients, but it’s
// important that controls build the complete pathname.
GetModuleFileName(hClientInstance, szLitgenFilename, MAX_PATH);
PathRemoveFileSpec(szLitgenFilename);
PathAppend(szLitgenFilename, "litgen.dll");
hLitgen = LoadLibrary(szLitgenFilename);
CreateWriter = (WriterCreator)GetProcAddress(hLitGen, "CreateWriter");
hr = CreateWriter(&pUnkLitWriter);
hr = pUnkLitWriter->QueryInterface(IID_ILITWriter, &pLitWriter);
© 2000 Microsoft Corporation. All rights reserved. Terms of use.