Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1508
  • Last Modified:

ActiveX control registering

I have created an activeX control in VB6, currently empty and does nothing. I compiled it to an ocx and opened it with regsvr32.exe.

I now want to use it in VC++, i create a project, goto "Add to project -> Components and controls", select the ocx and i get the message: "The activex control is not registered properly, or its type library version number is incorrect. Try registering the control by removing and importing it in the Component Gallery".

How do i remove and import it in the component gallery? what else can it be? thanks...
1 Solution
AndyAinscowFreelance programmer / ConsultantCommented:
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 may be necessary to troubleshoot some issues with Windows, Microsoft Internet Explorer, or other programs. For example, the following article in the Microsoft Knowledge Base requires you to use Regsvr32.exe to unregister the Wuv3is.dll control before you reinstall it from the Windows Update site:

Q241122 WINUP- Invalid Page Fault in 'wuv3is.dll'
If the registration of a control is unsuccessful or you need developer information about troubleshooting unsuccessful OLE control registration attempts, please see the following article in the Microsoft Knowledge Base:
Q140346 Possible Reasons for OLE Control Registration Failure

Regsvr32.exe is included with Microsoft Internet Explorer 3.0 or later, Windows 95 OEM Service Release 2 (OSR2) or later, and Windows NT 4.0 Service Pack 5 (SP5) or later. Regsvr32.exe is installed in the System (Windows Me/98/95) or System32 (Windows NT) folder.

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:
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
The following list contains RegSvr32 error messages and possible causes.

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

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.

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:
deniX23Author Commented:
I successfuly registered it with regsrv32.exe, and it works fine when adding it to  a VB6 project, the problem is only with VC++
AndyAinscowFreelance programmer / ConsultantCommented:
Have you changed the ocx or moved it's location since registering it?  (Maybe simpler to unregister and register it again).
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

deniX23Author Commented:
I tried to unreg and reg again, still the same problem
AndyAinscowFreelance programmer / ConsultantCommented:
for register
goto Start-->RUN--> type
regsvr32 <path of .ocx>  
press "ok"

for unregister

regsvr32  /u <path>
I tried creating a blank ActiveX control in VB 6.0 and registered it then used it normally with Visual C++ 6.0 and added it to an MFC dialog.

Try the following:
1. Try registering the control from VB by Selecting Project...Components... Then Browse to the folder of the control and select it. It will be added to the VB toolbox. That means it is definitely registered.

2. When selecting the control in VC++ 6.0. Select Add to Project...Controls and Components. Look for ProjectName.ControlName. Because this is the way the control is registered. Assume that you have the name of the project in VB prjTest and the control name Tester. Then you will look for prjTest.Tester in VC++ compoents - Registered ActiveX controls dialog.

I hope it will work for you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now