For install and shell sections, the LoadLibrary, FreeLibrary, and LibraryProcedure commands are available to load and unload the library module, and to call a function within the library. The following shows the syntax for these commands:
The LoadLibrary command loads the specified library file, and returns a handle to the loaded module. If the library file cannot be located, the Setup program displays an error message and terminates. The syntax of the LoadLibrary command is:
LoadLibrary DiskName DLLPath LibHandle
For example:
LoadLibrary "Setup Disk #1" a:\setupdll.dll LibHandle
The FreeLibrary command unmaps the specified library module, invalidating the handle. The syntax of the FreeLibrary command is:
FreeLibrary LibHandle
For example:
FreeLibrary $(LibHandle)
The LibraryProcedure command calls an exported function in the specified DLL. The syntax of the LibraryProcedure command is:
LibraryProcedure Result LibHandle FunctionName [Args]*
For example:
LibraryProcedure Result $(LibHandle) DLLFunc $(Arg0) $(Arg1)
The DLL function called by the LibraryProcedure command must provide a function whose prototype is shown below. Note that this prototype is different from that used for DLL functions called from a detect section.
BOOL PASCAL FunctionName(cArgs, lpszArgs[], *lpszTextOut)
DWORD cArgs;
LPSTR lpszArgs[];
LPSTR *lpszTextOut);
The function should return TRUE if successful or FALSE if an error occurs. The function is responsible for managing the memory allocated for the text buffer pointed to by lpszTextOut. If the function is successful, it can fill the lpszTextOut buffer with an arbitrary string, and the Setup program copies the text into the INF symbol table where it can be accessed using the Result variable. If an error occurs (that is, the function returns FALSE), the function should fill the lpszTextOut buffer with a descriptive error string. In this case, the Setup program’s default handling is to display the error string in a dialog box. This is treated as a noncritical error, with execution continuing and the value of the Result variable set to ERROR. This default error handling is overridden if the INF script has defined a FLibraryErrCtl variable with a value greater than zero. In this case, the error string is assigned to the Result variable, and the Setup program does not display the dialog.