Windows 95 Uses KnownDLLs Registry Key to Find 32-bit DLLs

ID: Q151646


The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows 95
  • Microsoft Win32 Software Development Kit (SDK), used with:
    • Microsoft Windows 95

IMPORTANT: This article contains information about editing the registry. Before you edit the registry, make sure you understand how to restore it if a problem occurs. For information about how to do this, view the "Restoring the Registry" Help topic in Regedit.exe or the "Restoring a Registry Key" Help topic in Regedt32.exe.

SUMMARY

The process of loading a DLL, 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 KnownDLLs Registry key have the ability to reset the normal search order used to locate and load a 32-bit DLL to a new predefined order. Thus, a string value that identifies a 32-bit DLL and is also associated with the KnownDLLs 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 used to locate and load a 32-bit DLL is specified as follows:

  1. The directory from which the application loaded.


  2. The current directory.


  3. The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.


  4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.


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


This search order is reset if:
  1. The DLL name passed to LoadLibrary specifies the .DLL extension.


  2. The 32-bit DLL specified has a Registry string value with the same name, excluding the extension, as the 32-bit DLL specified in the KnownDLLs Registry key. The KnownDLLs Registry key is located at:

    HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SessionManager


The data associated with the DLL string value must specify the actual DLL name for the DLL to be found and loaded. This DLL name does not need to match the string value name and is not required to following any naming convention. Some examples of such string values are:


      Name               Data
   -----------------------------------------------

     MYDLL1             MYDLL.DLL
     MYDLL2             MYREALDLL2.DLL 


When a string value for a 32-bit DLL exists, the new search order in the Windows system directory is as follows:
  1. If MYDLL1.DLL is passed to LoadLibrary, the Registry key MYDLL1 is used to load MYDLL.DLL.


  2. If the DLL name specified in the data value, MYDLL.DLL for example, cannot be found, LoadLibrary on MYDLL1.DLL will fail and a call to GetLastError will return error 2 "The system cannot find the file specified".


  3. If MYDLL.DLL or MYDLL is passed to LoadLibrary, the normal search pattern is used to locate and load MYDLL.DLL.


Following are ways that this DLL string value can be added to the Registry:
  • An end user can use Regedit.exe to add the 32-bit DLL string value to the KnownDLLs Registry key.

    -or-


  • The 32-bit DLL string value can be added programmatically to the Known32DLLs Registry key using Registry APIs.


To revert back to the default search pattern, the Registry key must be removed.

WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.

For information about how to edit the registry, view the "Changing Keys And Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Note that you should back up the registry before you edit it. If you are running Windows NT, you should also update your Emergency Repair Disk (ERD).

Additional query words: search path loadlibrary win95 order

Keywords : kbenv kbprg kbusage kbDLL kbKernBase kbGrpKernBase
Version : 4.00
Platform : WINDOWS
Issue type :


Last Reviewed: March 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.