ActiveX Control, ActiveX Server, and Type Library Registration

Updated May 4, 2018

Reported In

Software

  • Measurement Studio Standard
  • Measurement Studio Professional
  • LabVIEW

Issue Details

  • How do I manually register ActiveX controls (.ocx), ActiveX servers (.DLL and .EXE), and type libraries (.TLB) on my computer?
  • When opening a reference to my ActiveX control or class in LabVIEW, I get Error -2147221164: Class not registered. How do I prevent this error?

Solution

ActiveX controls, servers, and type libraries must be registered with the operating system before they can be called from LabVIEW. 

ActiveX Controls:
ActiveX controls are files with an .ocx extension. These controls come in 16-bit and 32-bit forms, with 32-bit being the most common. To register an ActiveX control, you should use Regsvr32.exe as follows:
  1. Select Start»Run.
  2. Type the following in the dialog box that appears:
    regsvr 32 "<Full path of .ocx file>"
    where "<Full path of .ocx file>" is the locations of your control, including quotes. The image below shows an example of registering mswinsck.ocx. You will need to replace the file path and name of the ActiveX control you want to register.

    Note: If you have a 16-bit control, you should run Regsvr instead of Regsvr32. If your ActiveX control is registered incorrectly, you must first unregister it (by using the switch /u as part of the command, i.e regsvr32 /u "<Full path of .OCX file>") and then register it again. You will get a dialog box alerting you that your control has been unregistered or registered successfully. 


    Note: If you have a 64-bit Windows, there is a 32-bit version of Regsrv32 and a 64-bit version of Regsrv32. The 64-bit version of Regsrv is in the System32 folder, while the 32-bit version is in the SysWOW64 folder. By default, the 64-bit version of Regsrv will run. 
 

ActiveX Servers
ActiveX servers can be in the form of dynamic link libraries (.DLLs) and executables (.EXEs). DLLs are registered like an ActiveX control with regsvr32 as in the previous section. However, when registering an .EXE, you must use call the .EXE file with the switch /RegServer as follows:

  1. Select Start»Run.
  2. Type the following in the dialog box that appears:
    <Full path of the .EXE file> /RegServer where <Full path of the EXE file> is the location of your .EXE server. For example:
    C:\TestStand\Bin\REngine.exe /RegServer
    Note: To unregister an .EXE ActiveX Server use the switch /UnRegServer. For example:
    C:\TestStand\Bin\REngine.exe /UnRegServer

Type Libraries
Type libraries (.TLB) are binary files that contain all of the type information needed to utilize the procedures and classes in a .DLL. To register a type library, you should use regtlibv12.exe (formerly regtlib.exe). Follow these steps to use regtlibv12.exe
  1. Navigate to the following folder and copy the file path to clipboard:
    C:\Windows\Microsoft.NET\Framework\v4.0.30319/regtlibv12.exe
    Note: In some situations,  such as on newer versions of Windows, you may not have regtlibv12.exe on your system. If you do not have regtlibv12.exe on your system, you can instead use Regasm.exe.
    Note: The actual folder path may be different depending on the .NET Framework version installed on your computer. This may also be located in C:\WINDOWS\system32\URTTemp\regtlib.exe
  2. Select Start»Run.
  3. Type the full location of this executable into the box that appears as: 
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe "<Full path of .TLB file>
    where "<Full path of .TLB file>" is the location of your type library file with quotations.
  4. Click OK.

Additional Information

Visit Microsoft Support articles for further information on registering ActiveX controls. More information about Regasm.exe can also be found on Microsoft's website

WAS THIS ARTICLE HELPFUL?

Not Helpful