Method 1: Running on the DOS or Windows command line: regsvr32 ocxname.ocx registration
Example:
Regsvr32 netshare.ocx // Register Netshare.ocx control
Regsvr32 / u netshare.ocx // Release of NetShare.ocx controls
If the NetShare.ocx file is not in the System directory, you must also add a complete path before the file name. In addition to the Regsvr32 application, Microsoft also provides a program called Regclean.exe on its Web site that checks the registry and removes the entry in the registry. Regclean.exe can delete the "suspension" entry, it also provides a "undo" file to help restore the error deletion.
Using Regsvr32.exe Registering ActiveX Controls Although it is simple, it is necessary to manually register. If you need to manually release it.
Method 2: Use Install Shield, select "Self-Registered" inside, the installer will automatically register
Method 3: API function registration
The design idea of this method is to first load the ActiveX control into memory and then verify its validity, and finally perform its registration function (DllRegisterServer, undllregs) in the memory address. Its programming method is:
1. Use the Windows API function loadLibrary to load the ActiveX control;
2. Use the getProcAddress function to get the registration function DllRegisterServer in the ActiveX control;
3. Use the CallWindowProc function to perform the ActiveX control registration function that loaded into the memory (DllRegisterServer, UndllRegisterServer).
Example:
TypedEf Int (Callback * Myfunction) (VOID);
Myfunction myfunction = null;
Hinstance Handle = NULL;
Handle = loadingLibrary ("trdragdroptreectrl.ocx");
IF (Handle! = NULL)
{
MyFunction = getProcaddress (Handle, "DLLREGISTERSERVER");
IF (MyFunction! = NULL)
{
Myfunction ();
}
}
Small experience: 1. Sometimes it is invalid when using the OCX control in the program, check whether Afxoleinit () is performed between the calls. If the container is used, it is also necessary to ensure an AFXENABLECONTROLCONTAINER () 2, using ActiveX Control Test Container to easily test the created OCX control (from the start menu - "program -" Microsoft Visual Studio 6.0-> Microsoft Visual Studio 6.0 Tools You can see the tool) 3. Sometimes there is no problem with the control, the registration method is also right, but if you register, it is failed. Maybe the version of the DLL is not right, use DependenCIES to view the OCX control dependent DLL to use the DLL version Consistent