HOWTO: Win95 Uses Known16DLLs Registry Key to Find 16-bit DLLs

ID: Q141969


The information in this article applies to:


SUMMARY

The process of loading a DLL for the first time, implicitly or explicitly, invokes Windows 95 to search for the specified DLL in a predefined order until the DLL is found or all search efforts are exhausted. In Windows 95, the string values associated with the Known16DLLs registry key have the ability to reset the normal search order used to locate and load a 16-bit DLL to a new predefined order. Thus, a string value that identifies a 16- bit DLL and is also associated with the Known16DLLs registry key will force Windows 95 to begin its search for the DLL in the System directory - not the current directory.


MORE INFORMATION

In Windows 95, the predefined order that is used to locate and load a 16-bit DLL is specified as follows:

  1. The current directory.


  2. The Windows directory (the directory containing Win.com).


  3. The Windows system directory (the directory containing such system files as Gdi.exe).


  4. The directory containing the executable file for the current task.


  5. The directories listed in the PATH environment variable.


NOTE: If a 16-bit DLL is already loaded by some running application, Windows 95 does not search for the DLL to load, even if the full path name is supplied to LoadLibrary. Instead Windows 95 will resolve the imports to link to the DLL already in memory.

This search order is reset if a 16-bit DLL being loaded has a string value with the same name as the 16-bit DLL specified in the Known16DLLs registry key. The Known16DLLs registry key is located at:


   HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager 


The data associated with the DLL string value can take any form. An example of such a string value is:


Name                       Data
-----------------------------------------------
"COMMCTRL.DLL"             "SYSTEM COMMCTRL.DLL" 


When a string value for a 16-bit DLL exists, the new search order is as follows:
  1. The Windows system directory.


  2. The Windows directory.


  3. The current directory.


  4. The directory from which the application loaded.


  5. The directories that are listed in the PATH environment variable.


There are three ways that this DLL string value can be added to the registry:
The first two ways to add the 16-bit DLL string value are basic and require no further explanation; however, the third method is more complex. Each time a 16-bit DLL is loaded from the Windows System directory, Windows 95 checks the Known16DLLs registry key for a string value that has that same name. If the string value does not exist, Windows 95 creates it in the Known16DLLs registry key. Thus, any application that uses a DLL that has the same name as a DLL listed in the Known16DLLs registry key will always use the reset search order to locate the DLL. As long as the DLL exists in the Windows System directory and can be loaded by another application, deletion of the string value will not be effective in returning the search order to its original predefined state.

Additional query words: search path 16 3.1 loadlibrary win95 order


Keywords          : kbenv kbDLL kbKernBase kbGrpKernBase 
Version           : 4.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: March 7, 1999