About Windows ActiveX Control Registration
2000-03-21 · Chen again · STU93J
Since Microsoft launched ActiveX technology in 1996, ActiveX technology has received many software companies support and responded to ActiveX technology in their products. The ActiveX control as one of ActiveX technology has also been rapidly developed, which not only launched a lot of ActiveX controls, but ActiveX controls got a favorite of general developers. So what is the ActiveX control? The ActiveX control is a dynamic link library that is operated as a COM server and can be embedded in the Packlergery host application, and the predecessors of the ActiveX control are OLE controls. Since the ActiveX control is not related to the development platform, the ActiveX control developed in a programming language can be used in another programming language, which is as used as using the Windows General Control. Such as: ActiveX control developed in VC , can be applied to VB without any modifications. It can be seen that the fast-scale component reuse can be realized by using the ActiveX control, and the code sharing is implemented, thereby increasing the programming efficiency. From the above, it can also be seen that the ActiveX control is so widely welcomed by developers. Because the reusability of the ActiveX control, the ActiveX control has been greatly developed. Currently, there are quite a number of ActiveX controls from the Internet, and there are many varieties, and the tasks completed are almost omnipotent. For ordinary developers, as long as they are patient, they can find ActiveX controls that meet their requirements on the Internet. ActiveX control from the Internet, or ActiveX controls obtained from other ways, how should users do correctly use ActiveX controls or apply it to their own programs? In general, an external ActiveX control is used correctly in Windows, first of all, you must copy the control file (* .ocx) into the hard disk, then register it in Windows, and the ActiveX control registered in Windows is not available. in use. Registering an ActiveX control generally has three ways: 1. Register the ActiveX control using the Regsvr32.exe program; 2. Use the installer production software: installshield; 3. Add registration code in the application. The above method is different from the scope of application, and each has its own advantages, discussed below. First, use the Regsvr32.exe program to register the ActiveX control for unregistered ActiveX controls to register it with this software, and the ActiveX control must be registered in your own program. This file is located in the system subdirectory of the Windows directory. The method is as follows: Click "Start" → "Run"; enter the following command in the Run dialog: Regsvr32
Regsvr32 / u
1. Use VC 6.0 to establish a single document app REGACTIVEX, other items accept default settings; 2. Add two menu items to the application: "Register ActiveX Control", "Logout ActiveX Control", steps are as follows: 1 Click VC 6.0 "ResOoureW" on the left window, double-click the IDR_MAINFRAME under the MENU project to open the menu editor; 2 In the menu editor, join a main menu "Register", join two menu items under the "Register" main menu: "Register ActiveX Controls, "Logout ActiveX Control"; 3. Add a response function to the new menu item "Register ActiveX Control" and "Logout ActiveX Control": 1 In the resource editing, double-click the IDR_MAINFRAME in MENU Open the menu editor, click "Register ActiveX Control", press CTRL W to open the MFC Class Wizard; 2 Double-click Command in the Messages box, add the response function onRegisterReg () to the "Register ActiveX Control" menu item, click the "Edit" button to the onRegisterReg () function. Added code: void cmainframe :: onRegisterReg () {
// ActiveX control path and file name
LPCTSTSTR PSZDLLNAME = "TowerTL.OCX";
// Load an ActiveX control
Hinstance Hlib = loadingLibrary (pszdllname);
IF (Hinstance Hinstance_ERROR)
{
MessageBox ("Cannot load DLL file!", "Results", MB_OK;
Return;
}
/ / Get the registration function DllRegisterServer address
FarProc LPDLLLENTRYPOINT;
LPDLLENTRYPOINT = GetProcAddress
(HLIB, _T ("DllRegisterServer");
// Call the registration function DllRegisterServer
IF (LPDLLLENTRYPOINT! = NULL)
{
IF ((* lpdllenTryPoint) ()))
{
MessageBox ("call DLLREGISTERSERVER
failure! "," Results ", MB_OK;
Freelibrary (HLIB);
Return;
}
MessageBox ("Successful Success", "Result", MB_OK;
}
Else
MessageBox ("call DllRegisterServer failed!"
, "Result", MB_OK);
} 3 "Logging Underwriting the ActiveX Control" menu item response function is similar to the same, the code is similar, just "lpdllentrypoint = getProcAddress
(HLIB, _T ("DllRegisterServer"); "Change:
LPDLLENTRYPOINT = GetProcAddress