About Windows ActiveX Control Registration

zhaozj2021-02-11  213

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 Register an ActiveX control

Regsvr32 / u Reissue ActiveX Control We use some applications with ActiveX controls, sometimes you can run, it is possible to have its own ActiveX control unregistered, then you can use it. The above command is trial. In addition, if VC users are interested in the Code of Regsvr32.exe, they can find their source code in the VC online help. If VC 6.0 is used, in the / Sample / VC98 / MFC / Controls / RegsVR of the MSDN CD. Second, use the installer production software: installShield uses regsvr32.exe to register the ActiveX control is simple, but users need to register manually, but also have to handle registration, so this is not a good solution for an application. Large applications typically have a installer that resolves the ActiveX control registration in the installer is a more ideal solution. Using InstallShield, you can make professional-grade Setup, you can also register the ActiveX controls;, when you carry software later, you can automatically log out of the previously registered ActiveX control. The method is as follows: 1. Start InstallShield, build a new project using Project Wizard; 2. New "File Group", put the ActiveX control file that you need to register into this "File Group"; 3. "File Group" The "Self-Registered" property is set to "Yes". The above steps are forced to set up automatically registering ActiveX controls in SETUP. As for how to use installshield how to make a complete setup is not in this paper discussion, please read the readers to see the books. Third, the addition of the registration code in the application is not appropriate to take the second method for small programs. The preferred method is to embed the registration code in the program to implement the application from registration. Its programming method is: 1. Use the Windows API function LoadLibrary load ActiveX controls; 2. Use the GetProcAddress function to get registered ActiveX controls function DllRegisterServer (logout function DllUnregisterServer) pointer; 3. Call registration function DllRegisterServer (or cancellation function DllUnregisterServer). The REGACTIVEX program written in VC 6.0 is taken as an example, which describes how to automatically register (log out) ActiveX controls in the program. The main frame of RegactiveX is automatically generated by the AppWizard of VC 6.0, adding two menu items on the basis: "Register ActiveX Control", "Logout ACTIVEX Control". When you select the "Register ActiveX Control" menu, register the control Toweratl.ocx (a Hanno game); when you select the "Logging ActiveX Control" menu, the registration of the control Toweratl.ocx will be released.

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

转载请注明原文地址:https://www.9cbs.com/read-4517.html

New Post(0)