RegSvr32 - DLL/OCX Registration Tool



You can use the Regsvr32 tool (Regsvr32.exe) to register and unregister object linking and embedding (OLE) controls such as dynamic-link library (DLL) or ActiveX Controls (OCX) files that are self-registerable.  This allows you to "run" a DLL as if it were an exe file.

When a DLL is registered you can "run" it as an executable by either adding it as a filetype in Explorer/Tools/Folder Options/File types tab - or from the command line using rundll32 - for example, WinXP's Picure and Fax viewer, shimgvw.dll :

 

rundll32.exe D:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen %1

NOTE: once registered - this dll has a problem un-registering.  It still opens images by default and stays in the File Types for jpg's - weird.

Regsvr32.exe is included with :

Regsvr32.exe Usage


RegSvr32.exe has the following command-line options:


Regsvr32 [/u] [/n] [/i[:cmdline]] dllname

 

/u - Unregister server<BR/>
/i - Call DllInstall passing it an optional [cmdline];
when used with /u calls dll uninstall
/n - do not call DllRegisterServer; this option must be used with /i


When you use Regsvr32.exe, it attempts to load the component and call its DLLSelfRegister function. If this attempt is successful, Regsvr32.exe displays a dialog indicating success. If the attempt is unsuccessful, Regsvr32.exe returns an error message, which may include a Win32 error code.  For a list of Win32 error codes, refer to the following Microsoft Web site:  http://msdn.microsoft.com/library/psdk/psdkref/errlist_9usz.htm

 

For example, to manually register a Sample.ocx ActiveX control, type the following command at an MS-DOS prompt:

 

c:\regsvr32.exe sample.ocx

Regsvr32.exe Error Messages


Unrecognized flag: /invalid_flag

You typed an invalid combination of flags or switches (refer to the
"Regsvr32.exe Usage" section in this article).

No DLL name specified.

You did not include a .dll file name (refer to the "Regsvr32.exe Usage"
section in this article). Dllname was loaded, but the DllRegisterServer or
DllUnregisterServer entry point was not found.

Dllname> is not a .dll or .ocx file. For example, typing regsvr32 wjview.exe
generates this error message.

Dllname is not an executable file and no registration helper is registered
for this file type.

Dllname is not an executable file (.exe, .dll, or .ocx). For example, typing
regsvr32 autoexec.bat generates this error message.

Dllname was loaded, but the DllRegisterServer or DllUnregisterServer entry
point was not found.

Dllname may not be exported, or a corrupted version of Dllname may be in
memory. Consider using Pview to detect the file and remove it.

Dllname is not self-registerable or a corrupted version is in memory.

For example, typing regsvr32 icwdial.dll returns this error message because
the Icwdial.dll file is not self-registerable. If you suspect a corrupted
version of Dllname is in memory, try restarting your computer or re-extract
the original version of the file. If you are running Windows NT, you may
need to use the Kill or Pview tool from the Microsoft Windows NT Server 4.0
Resource Kit. For additional information, click to view the following
article in the Microsoft Knowledge Base:
Q197155 How to Kill an Orphaned Process
OleInitialize failed (or OleUninitialize failed).

Regsvr32 must initialize the COM library before it can call needed COM
library functions and uninitialize the library when it shuts down. These
error messages occur if an attempt to initialize or uninitialize the COM
library is unsuccessful. For example, the Ole32.dll file may be corrupted or
may be the wrong version.

LoadLibrary("Dllname") failed. GetlastError returns 0x00000485

From Winerror.h, 0x00000485 = 1157 (ERROR_DLL_NOT_FOUND), which means "One
of the library files needed to run this application cannot be found." For
example, typing regsvr32 missing.dll returns this error message if the
Missing.dll file is not found.

LoadLibrary("Dllname") failed. GetLastError returns 0x00000002

From Winerror.h, 0x00000002 = 2 (ERROR_FILE_NOT_FOUND), which means "The
system cannot find the file specified." In other words, a dependent DLL was
not found. For example, typing regsvr32 icwdial.dll with Tapi32.dll (a
dependency) missing, returns this error message.

LoadLibrary("dskmaint.dll") failed. GetLastError returns 0x000001f

From Winerror.h, 0x000001f = 31 (ERROR_GEN_FAILURE), which means "A device
attached to the system is not functioning." This behavior can occur if you
try to register a Win16 .dll file. For example, typing regsvr32 dskmaint.dll
returns this error message.

DllRegisterServer (or DllUnregisterServer)in Dllname failed. Return code
was: string

NOTE:  you can search Winerror.h for string


Regsvr32.exe and Dependencies


RegSvr32.exe depends on the Kernel32.dll, User32.dll, and Ole32.dll files (and the Msvcrt.dll and Advapi32.dll files in Windows NT). Regsvr32.exe loads the file you are trying to register or un-register, along with all of its dependencies. The process may be unsuccessful if a required file is missing or damaged.

Depends.exe Usage

 

You can use Depends.exe to determine dependencies for the file you are trying to register or un-register. Depends.exe is included with the Microsoft Windows 98 Resource Kit and the Microsoft Windows NT 4.0 Resource Kit support tools. For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:

 

Q206848 Windows NT Service Pack 4.0 Tools Not Included on CD-ROM
Q247024 Tools Included with the Microsoft Windows 98 Resource Kit