Register DLL with Wise

1. What is a DLL and why register it?

According to Microsoft:

“A DLL is a library that contains code and data that can be used by more than one program at the same time. For example, in Windows operating systems, the Comdlg32 DLL performs common dialog box related functions. Therefore, each program can use the functionality that is contained in this DLL to implement an Open dialog box. This helps promote code reuse and efficient memory usage.

By using a DLL, a program can be modularized into separate components. For example, an accounting program may be sold by module. Each module can be loaded into the main program at run time if that module is installed. Because the modules are separate, the load time of the program is faster, and a module is only loaded when that functionality is requested.

Additionally, updates are easier to apply to each module without affecting other parts of the program. For example, you may have a payroll program, and the tax rates change each year. When these changes are isolated to a DLL, you can apply an update without needing to build or install the whole program again.”

https://support.microsoft.com/en-us/kb/815065

 

There are several types of DLL:

  • The “regular” ones, which export some functions (for example shell32.dll or user32.dll…). It’s not required to register them.
  • ActiveX Controls (.ocx) files. An example of an ActiveX control is a calendar control that lets you select a date from a calendar. These DLL have methods and properties, progid, classid or GUID. They must be registered.
  • Control Panel (.cpl) files. An example of a .cpl file is an item that is located in Control Panel. Each item is a specialized DLL. They are most of time located in the ProgramFiles folder, it’s not required to register them.
  • Device driver (.drv) files. An example of a device driver is a printer driver that controls the printing to a printer. They must be registered.

.

.

2. Registering a DLL again after repackaging?

When a package is created using snapshot capture, DLL are usually captured.

Some of them need to be registered again when installing the MSI.

Indeed, if a newer version of a DLL is installed on the machine, it contains additionally functions. So, registering the DLL again allows to make available these new functions.

Several reasons to register a DLL again after a snapshot capture:

  • The registration of a DLL has been detected during the capture, and this DLL appears in the project. That means that this DLL was not present on the machine before the installation.
  • The registration of a DLL has been detected during the capture, but this DLL does not appear in the project. That means that the DLL was already present on the machine before the installation and it has been registered again during the installation.
  • A DLL has been manually added after the capture, so its registration has not been detected.

.

.

3. Registration of a DLL captured during snapshot capture

Some applications, when installing, copy DLLs on the machine, and then register them in order to use their functions. In this case, the Wise project contains the .dll file and its registration.

But applications can also update a DLL already present on the machine (shared DLL, system DLL…). In this case, the Wise project contains the registration of the DLL but not the .dll file.

The registration of a DLL can be detected in the “Registry” table.

Go to:

  • Setup Editor
  • Table
  • Registry

Check all the registry entries containing CLSID and “InprocServer” or “InprocServer32

wiseregdll01

 

2 cases :

  • The file is present in the project: the value is like [#file.dll] or [!file.dll]
  • The file is not in the project: the value is like [SystemFiles]file.dll

.

.

3.1.  If the DLL is present in the project

The file is present in the project: the value is like [#file.dll] or [!file.dll]

Go to:

  • Setup Editor
  • Components

Display the details, then go to the Self-registration tab

wiseregdll02

Select Use order specified below and then validate.

 

Go to:

  • MSI Script
  • Installation Mode: All Custom Actions

wiseregdll03

 

  • Delete the Custom Action “unreg
  • Edit the registration Custom Action

wiseregdll04

EXE and Command Line

Replace: “[SystemFolder]msiexec.exe” /y “[#filekey]”

By: “[SystemFolder]regsvr32.exe” “[#filekey]” /S

 

Condition

Replace the existing condition by the following:

REINSTALL = “ALL” OR NOT Installed

 

Properties

Select « «Synchronus, Ignore exit code

.

.

3.2.  If the DLL is not present in the project

The file is not in the project: the value is like [SystemFiles]file.dll

Create the following Custom Action:

wiseregdll05

  • Custom Action Name
  • Working Directory : SystemFolder
  • EXE and Command Line : “[SystemFolder]regsvr32.exe” “[SystemFolder]MSVBVM60.DLL” /S (for example)
  • Sequence : “Normal Execute Immediate/Deferred” after “SelfRegModules
  • Condition : REINSTALL = “ALL” OR NOT Installed
  • Processing (Properties tab) : Synchronous, Ignore exit code

.

.

4. Registration of a DLL added manually

Sometimes, after the snapshot capture, it’s necessary to add DLL manually to the project, so we have to know if yes or no, this DLL has to be registered.

Wise provides a tool allowing to check if a DLL must be registered or not: WiseComCapture.exe

Here are the parameters of the tool:

wiseregdll06

WiseComCapture detects if the DLL has to be registered and create a reg file allowing the registration.

 

To check if a DLL requires a registration:

Enter the following command: WiseComCapture.exe –r [path to the reg]

wiseregdll07

WiseComCapture creates the reg file.

  • If the reg file contains registry entries, the DLL must be registered
  • If the reg file is empty, the DLL does not need to be registered

 

To register the DLL

If the reg file is not empty, the DLL requires to be registered.

2 methods:

  • Integrate the registry entries of the reg file in the project
  • Follow the same procedure as above (section 3.1)