I am adding this with the respect to my previous blog post regarding error message on 64-bit windows when you try run regsvr32.exe. Usually we – the developer customers –face the issue when you try to register. I want to update you that how the RegSvr32.exe program registers and unregisters a Component Object Model (COM) dynamic-link library (DLL).
Most often, RegSvr32.exe fails because the LoadLibrary, DllRegisterServer, or DllUnregisterServer function fails. In order to understand, we should understand how it works – RegSvr32.exe calls the following Win32 functions in this order:
- LoadLibrary to load the DLL
- DllRegisterServer or DllUnregisterServer
Most often, RegSvr32.exe fails because the LoadLibrary, DllRegisterServer, or DllUnregisterServer function fails. LoadLibrary can fail if the DLL is not in the specified path, or if the specified path is incorrect. LoadLibrary can also fail if one of the dependencies of the DLL that you are trying to load is not met; in other words, if a dependent DLL is not present or is not in the specified path.
How to troubleshoot?
- Your DLL must implement DllRegisterServer and DllUnregisterServer, which contain the logic that is necessary to add or delete the required registry entries for the COM component. RegSvr32.exe finds the entry point to these functions, and calls them appropriately.
- You can use the Depends.exe tool to check whether or not all of the dependencies of your DLL are met. Depends.exe is included with the Microsoft Platform Software Development Kit (SDK), which ships with Microsoft Visual Studio. For example, i am trying to see the dependencies of ‘Notepad.exe’ using Depends.exe. (click to enlarge the picture)
Also i would recommend to refer the following KB article: http://support.microsoft.com/kb/207132/en-us – which has a win32 application sample describes registry functions that you can use to register and unregister your COM DLL. You can also write your own code to do what RegSvr32.exe does. This helps to identify, isolate, and troubleshoot errors more easily.