Solved

ActiveX control registering

Posted on 2004-08-26
7
1,424 Views
Last Modified: 2013-11-20
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...
0
Comment
Question by:deniX23
7 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
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



MORE INFORMATION
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:
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
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:
0
 

Author Comment

by:deniX23
Comment Utility
I successfuly registered it with regsrv32.exe, and it works fine when adding it to  a VB6 project, the problem is only with VC++
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Have you changed the ocx or moved it's location since registering it?  (Maybe simpler to unregister and register it again).
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:deniX23
Comment Utility
I tried to unreg and reg again, still the same problem
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
?
0
 

Expert Comment

by:rpatna
Comment Utility
for register
goto Start-->RUN--> type
regsvr32 <path of .ocx>  
press "ok"

for unregister

regsvr32  /u <path>
0
 
LVL 6

Accepted Solution

by:
nabehs earned 125 total points
Comment Utility
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.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now