How to Register a DLL
Dynamic Link Library files or DLLs are libraries of computer code and data that are used as shared resources on computers running the Windows Operating System (OS). A common task that arises for home computer users is figuring out how to register a DLL to allow the desired computer software to operate properly. The act of registering a DLL updates the Windows registry with the location and capabilities store in the file to permit proper application execution. The two options available to complete this task are through self-registration or manual action.
What Is a DLL?
A DLL (Dynamic Link Library) is a grouping of files that include both data and executables that are able to be used by one or more programs at the same time. The use of DLLs promotes code reuse by Windows applications developers and more efficient use of memory on computers running the Windows operating system (OS). Through the use of DLLs, program development is able to be modularized into separate components or modules enabling a faster load time of programs when these modules are loaded as the functionality is required. The use of DLLs also allows separate program modules to be updated without having to completely install new versions of programs saving time and bandwidth for consumers.
What Are Common DLLs?
There are a number of common DLLs used by two or many computer applications on the Windows OS. These include ActiveX Control, Control Panel, and Device driver files. For example:
ActiveX Control Files (.ocx) – can perform a variety of reusable functions and are comparable to Java applets in their functionality. First introduced by Microsoft in 1996 as part of their Component Object Model (COM) and Object Linking and Embedding (OLE) technologies.
Control Panel Files (.cpl) – There is a control panel file for every item located or listed in the Windows Control Panel. Each is a specialized file that may reference zero or more additional DLLs.
Device Driver Files (.drv) – There are one or many device driver files for each hardware component installed on a Windows computer. One of the more prevalent are those installed for printers or network adapters.
Advantages of Dynamic Link Library Files
DLL files were developed and supported to increase performance and efficiency on computer programs running on the Windows OS. Some of the noted advantages for the use of DLLs include:
- Fewer computer resources are required to support common tasks. The use of DLLs can result in an overall decrease of the duplication of computer code loaded on the hard drive and placed in physical memory.
- Encourages the use of modular programming architecture. Aids developers that require multiple versions (for example basic to advanced support or multi-language), and supports dynamic loading of functionality at run-time.
- Reduces complications with program deployment and installation. If a specific functionality has to be updated or corrected within a support DLL, the entire program does not have to be upgraded or relinked with the DLL. All programs relying on the problematic file will benefit from the revision without further action. More frequently occurs with third-party DLL files.
The Problem with DLL Dependencies
When a computer application or dynamic link library uses a function call from another DLL, a dependency on that library is created. If changes are made to the supporting library, unintended consequences have been known to result placing the user in what is known in laymen’s terms as “DLL Hell.” Supporting programs may not execute at all or properly if any of the following DLL actions occur:
- Dependent DLL is “corrected” or “fixed” without analyzing the public interfaces that other programs may rely upon.
- Dependent DLL is upgraded to a new version that does not have backwards compatibility.
- Dependent DLL is overwritten with an older version of the library.
- Dependent DLL is removed from the computer.
Microsoft refers to these actions as “DLL conflicts” that most commonly occur from lack of enforcement on the part of developers with backward compatibility. Although the problem was more prevalent on Windows OS applications that support legacy 16 bit editions, they can still arise today.
How Microsoft Helps Us Avoid DLL Hell
There have been a number of changes implemented by Microsoft to minimize the risk of DLL conflicts or dependency issues over the past several years. These include the incorporation of Windows File Protection, and Private DLLs.
Under Windows File Protection, the OS precludes system DLLs from being deleted or updated by unauthorized programs. When a new or existing application installation attempts to update or remove a DLL that is protected, a valid digital signature must be presented. If there is not one, then the update or deletion is prevented by the OS.
The use of Private DLLs is the second innovation deployed by Microsoft to help protect applications from changes made to shared DLL files. In this concept, the private DLL saves version specific data on the one or many DLL support files used by the program. In this concept, the private DLL tells the OS to use the version saved in the program root folder if the shared instance has been revised since application deployment.
DLL Troubleshooting Tools
There are a number of tools that have been deployed to help computer users and developers trouble shoot DLL issues on their computer. These include Dependency Walker, DLL Universal Problem Solver, Dlister.exe, Dcomp.exe, and Dtxt2DB.exe. The Dependency Walker tool recursively scans for all dependent DLLs used by a program and helps developers or power users document all of the DLLs used by a program. This can then help troubleshoot potential future issues incurred by operating system or third party application program updates. The tool is installed as par to Microsoft Visual Studio.
Another common DLL troubleshooting tool is the DLL Universal Problem Solver. This application audits, compares, documents, and displays DLL information for a specific program or application. Deployed as part of this tool are support applications such as Dlister.exe that lists all DLLs installed on a given computer and saves the information to a text or data base file, Dcomp.exe that is able to compare DLLs listed in two text files and identify differences, and Dtxt2DB.exe which will load these text files into a dllHell database. The DlgDtxt2DB.exe combines these functionalities into a single program that uses a graphical user interface vice command line interaction.
How to Self-Register a DLL File
Most DLL files deployed today are self-registering as part of a computer program installation. The file(s) will include the relevant information to store them in the Windows OS registry and require no human intervention to do so. Once a self-registered DLL file is stored on a computer, they are accessible when required by one or many computer applications. Other file types that are capable of self-registration include ActiveX controls and Windows executable files. Of note, to manually remove a self-registered DLL file can require manual action on the part of the end-user.
How to Manually Register DLL Files
The second way or method to register DLL files on the Windows OS is through manual registration.
Step 1 – Login to the computer with an account that has administrator or equivalent permissions.
Step 2 – Click the “Start” menu button and enter “cmd” or “command” in the search text field depending on what version of Windows is installed on the computer.
Step 3 – Enter regsvr32 “path and FileName.dll” at the DOS command prompt followed by pressing the “enter” key. The path is the actual location of the DLL file or directory on the computer’s hard or networked drive. A sample of this entry is:
Step 4 – After the DLL has been successfully registered on the computer, a dialogue box will be displayed confirming registration. The message will include the name of the newly registered DLL file and confirm entry into the Windows registry.
Regsvr32 Command Line Options
Regsvr32.exe is installed on computers running Microsoft Internet Explorer 3.0 or newer. For users who own 64 bit versions of the Windows OS, there are two versions of the DLL registration utility located on the computer:
64-bit version is located here: %systemroot%\System32\regsvr32.exe.
32-bit version is located here: %systemroot%\SysWoW64\regsvr32.exe.
The following command line options are available with either version of the utility program:
/u – Unregister server
/i – Call DllInstall passing an optional [cmdline]. When the switch is used with /u, will call dll uninstall
/n – do not call DllRegisterServer. This command line switch has to be used with the /i option.
/s – Silent mode. Do not display any message boxes (new since Windows XP)
Command Line tool use:
Regsvr32 [/u] [/n] [/i[:cmdline]] dllname
When the Regsvr32.exe application is run, it will attempt to load the identified component and then invoke the DLLSelfRegister function. If this works, then the success dialogue box will be displayed. If it does not work, an error message will be returned to the end-user which may or may not include an applicable Windows error code.
Common DLL Error Messages
Despite significant improvements in reducing DLL conflicts over the past several years, there are still a number of error messages that can result from attempting to register DLLs using the Regsvr32.exe tool. The following listing contains common errors along with potential causes for Windows Vista and newer versions of the Windows OS:
The command-flag “”%1″” is not valid. Please review the command usage and try again.
Cause: The user entered an invalid combination of command line switches or arguments when invoking the regsvr32.exe application.
This command is only valid if a Microsoft Visual Studio OLE Custom Control project is opened.
Cause: Microsoft Visual Studio invoked or ran the regsvr32.exe application but there were not modules included in the command line arguments.
To register a module, you must provide a binary name.
Cause: Regsvr32.exe was invoked or called with no modules to register located in the command line arguments..
The command OleInitialize failed to run. Your computer might be low on memory. Close any open programs and then try again.
Cause: The regsvr32.exe tool has to initialize the Microsoft COM library before calling the required COM library functions. It also has to unitialize the library when it shuts down. Typically results when either action has failed. If no cause can be determined, can sometimes be solved through restarting the computer system.
The module “”%1″” failed to load.\n\n Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files.\n\n%2.
Cause: Windows had issues with loading the module identified in the command line. The specific error text will be provided as part of the message.
The module “”%1″” was loaded but the entry-point %2 was not found.\n\nMake sure that “”%1″” is a valid DLL or OCX file and then try again
Cause: The regsvr32.exe application was not able to locate the entry point to the module identified in the command line. This commonly results from improper entrypoint exportation from the module or if the file is not truly a DLL or .OCX file.
The module “”%1″” was loaded but the call to %2 failed with error code %3.\n\nFor more information about this problem, search online using the error code as a search term.
Cause: When regsvr32.exe invoked the entrypoint in the DLL module an error was thrown. The specific error code will be included with the displayed message.
The module “”%1″” may not compatible with the version of Windows that you’re running. Check if the module is compatible with an x86 (32-bit) or x64 (64-bit) version of regsvr32.exe.
Cause: Commonly occurs if the 32 bit version of regsvr32.exe is run with a 64 bit version of the DLL.