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

Last reviewed: July 1, 1996
Article ID: Q151646
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface included with:

        - Microsoft Windows 95
    
  • Microsoft Win32 Software Development Kit for:

        - Microsoft Windows 95
    

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.


Additional reference words: search path loadlibrary win95 order
KBCategory: kbenv kbusage kbprg
KBSubcategory: BseDll




THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 1, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.