Method for dynamically calling ActiveX plug-in interface based on JavaScript Proxy
Dynamically calling the ActiveX plug-in interface through JavaScript Proxy technology solves the problem of calling the ActiveX plug-in interface without writing JavaScript scripts, reduces development complexity and labor waste, and improves development efficiency and system flexibility.
Patent Information
- Application Number
- CN202411094472.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-10
- Publication Date
- 2024-10-01
AI Technical Summary
The existing technology is difficult to dynamically call unknown ActiveX plug-in interfaces without writing JavaScript scripts, and requires understanding browser middleware technology and writing a large number of scripts, resulting in a waste of manpower and high complexity of system development.
Using JavaScript Proxy technology, define the AxObject class as the JavaScript proxy of the ActiveX plug-in, remotely call the ActiveX plug-in Dispatch interface through the Invoke method, use Json data packaging and unpacking to implement dynamic calls, and build an AxObjectHandle object to intercept property and method calls, and generate an AxProxy object to maintain Traditional JavaScript calling style.
There is no need to understand browser middleware technology or write JavaScript scripts to call the ActiveX plug-in interface, which reduces development difficulty, improves development efficiency, enables on-demand calls, and adapts to plug-in interface upgrades to keep business logic consistent.
Smart Images

Figure CN118733150A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of browser plug-ins, and in particular to a method for dynamically calling an ActiveX plug-in interface based on JavaScript Proxy. Explanation of terms
[0002] Proxy: It is an API introduced in JavaScript ES6 that allows to establish an "interception" layer before the target object. This interception layer defines that when the program reads or sets the property of the object, it will first enter this "interception" layer and then decide whether to continue the operation.
[0003] ActiveX plug-in: It is Microsoft's name for a series of strategic object-oriented programming technologies and tools, the main technology of which is the Component Object Model (COM). ActiveX plug-in can be embedded into IE browser web pages through ActiveX technology, and interact with web pages, adapt to various application environments, realize complex functions, and provide the ultimate user experience.
[0004] ActiveX plug-in interface: The ActiveX plug-in interface includes the plug-in's read properties, write properties, and methods.
[0005] Plug-in container program: It is an independent program responsible for the creation of ActiveX plug-ins, position and size updates, display and hide control, ActiveX plug-in interface calls, plug-in destruction and other operations.
[0006] Browser middleware technology: Modern browsers that originally did not support ActiveX plug-in technology, such as Google, Firefox, Edge, etc., can embed ActiveX plug-ins with the help of browser middleware technology.
[0007] Modern browsers: refers to H5 browsers represented by Google, such as Google, Firefox, Edge, 360, etc. Background Art
[0008] As Microsoft stops serving IE browser, the once glorious IE browser has withdrawn from the stage of history, which has caused a large number of ActiveX plug-ins that were once safe, reliable, convenient and easy to use to become unusable. At present, some manufacturers use middleware technology to implement modern browser applications of ActiveX plug-ins. Since the plug-in object constructed by the middleware is not a plug-in object inside the browser, the internal object interface of the middleware cannot be accessed using the traditional JavaScript plug-in object. Therefore, it is necessary to write the corresponding JavaScript script according to the ActiveX plug-in interface for the browser page to call; the browser page calls the middleware-related JavaScript script, sends the method name and parameters and other information to the middleware through the network, and the middleware calls the interface corresponding to the ActiveX plug-in based on the above information, and returns the execution result of the interface through the network. This requires knowing the properties and methods of the ActiveX plug-in in advance, and writing the corresponding JavaScript script according to its interface (in order to ensure that the browser page calls the plug-in style consistent with the ActiveX plug-in call style in the traditional browser, each interface of the JavaScript class object needs to be consistent with the ActiveX plug-in interface), so that the browser page call can be realized.
[0009] Since there are many ActiveX plug-ins on the market, the plug-in interface cannot be predicted in advance, and browser page developers need to have certain learning and integration capabilities, and write corresponding JavaScript scripts according to the properties and methods of the ActiveX plug-in, so as to use this type of middleware technology to integrate the ActiveX plug-in into the browser page and call the interface.
[0010] Secondly, since some ActiveX plug-ins have many interfaces, writing corresponding JavaScript scripts is a lot of work, which causes a huge waste of manpower. For example, the Office VBA interface hierarchy is complex and has many interfaces. If every interface of every object is implemented, it will be a very large task.
[0011] Therefore, a method for dynamically calling an ActiveX plug-in interface with JavaScript is urgently needed. The method can realize dynamic calling of an unknown ActiveX plug-in interface without writing a JavaScript script of the plug-in interface, and at the same time, keep the style of traditional browser page JavaScript calling the ActiveX plug-in interface.
[0012] The traditional way of writing JavaScript scripts according to the ActiveX plug-in interface has the following disadvantages: 1. System developers need to learn browser middleware technology, which places high demands on developers; 2. It is necessary to write JavaScript scripts corresponding to the ActiveX plug-in interface, which results in a huge waste of manpower; 3. Only corresponding JavaScript scripts can be provided in advance for known ActiveX plug-ins. When the plug-in interface is upgraded or changed, it needs to be adjusted synchronously.
[0013] Purpose of the present invention: The present invention solves the problem of not writing a JavaScript script corresponding to the ActiveX plug-in interface, while still maintaining the traditional JavaScript interface calling style, and implementing the interface calling of the browser page to the ActiveX plug-in.
[0014] Beneficial effects of the present invention: 1. System developers do not need to understand the technical details of browser middleware, and can call the ActiveX plug-in interface without writing the ActiveX plug-in interface JavaScript script, which reduces the difficulty of connecting with browser middleware products and greatly improves development efficiency; 2. The browser middleware JavaScript calling method is consistent with the original browser plug-in interface JavaScript calling style. When upgrading the old system, only some codes need to be adjusted without modifying the business logic to achieve business integration and system upgrade; 3. It is beneficial to improve the operating efficiency of the browser. Since the JavaScript of the present invention dynamically calls the ActiveX plug-in interface, on-demand calling is realized without loading all interfaces of the ActiveX plug-in in advance; Summary of the invention
[0015] The present invention overcomes the deficiencies of the prior art and provides a method for dynamically calling an ActiveX plug-in interface based on JavaScript Proxy.
[0016] A method for dynamically calling an ActiveX plug-in interface based on JavaScript Proxy comprises the following steps: S1: Define a JavaScript class AxObject as the JavaScript proxy of the ActiveX plug-in Dispatch interface. The AxObject has an initialization method constructor for object initialization; an obj attribute for recording the Dispatch interface identifier; and an Invoke method for remotely calling the ActiveX plug-in Dispatch interface. Further: the Invoke method of the AxObject is a JavaScript indefinite length parameter method; Further: In the Invoke method of the AxObject, the first parameter of the arguments built-in object is the plug-in interface name N1; the rest are the plug-in interface parameter array Params; Further: in the Invoke method of the AxObject, each parameter param in the plug-in interface parameter array Params is traversed, and when the param type is object, it is replaced with the attribute obj value of the AxObject object, indicating the identifier of the corresponding plug-in Dispatch interface; Further: in the Invoke method of the AxObject, the interface call command CMD, the obj attribute of the AxObject class, the plug-in interface name N1, and the plug-in parameter array Params are packaged into Json data J1; Further: in the Invoke method of the AxObject, the Json data J1 is sent to the plug-in container program in step S2 through the network, the plug-in container program returns the plug-in interface execution result R1, the Invoke method of the AxObject parses the execution result R1, obtains the plug-in interface return value R2 and returns the return value R2, thereby realizing the remote call of the ActiveX plug-in Dispatch interface.
[0017] S2: The plug-in container program calls the ActiveX plug-in interface and returns the interface execution result: The plug-in container program parses the Json data J1 of the Invoke method of the AxObject object in step S1, and obtains the interface call command CMD and the obj attribute of the AxObject class, the plug-in interface name N1, and the plug-in parameter array Params information. According to the interface call command CMD, the ActiveX interface dynamic call module is called, and the corresponding ActiveX object Dispatch interface Disp1 is searched through the obj attribute of the AxObject class; according to the plug-in interface name N1, the interface ID of the method name N1 in the Dispatch interface Disp1 is obtained, recorded as DispID1; if the DispID1 is less than 0, it means that the interface does not exist, and the execution error code is returned; otherwise, all members of the parameter array Params are converted into variant variable type varParams; the DispID1 and the varParam are used as parameters to call the Invoke method of the Dispatch interface Disp1 to obtain the return value R2. Convert the return value R2 and the execution error code into a Json string J2, and send the Json string J2 to the Invoke method of the AxObject object in step S1 through the network; Furthermore, if the plug-in interface name N1 begins with a fixed mark Pre, indicating that the plug-in is called to write properties, before obtaining the interface ID of the Dispatch, the fixed mark Pre should be removed, the property name Prop should be obtained, and the plug-in object write property interface call can be implemented by calling the Disp1 object Invoke method; otherwise, the interface ID of the Dispatch interface Disp1 can be directly obtained, and the plug-in object read property or method interface call can be implemented by calling the Disp1 object Invoke method; Furthermore, if the return value R2 is a Dispatch interface, the plug-in container program should manage the Dispatch interface to facilitate subsequent calls to the Dispatch interface; S3: Construct the processor AxObjectHandle object of JavaScript Proxy: the implementation of the get method of the processor AxObjectHandle object intercepts the call of the AxObject class to read properties and methods; the implementation of the set method of the processor AxObjectHandle object intercepts the call of the AxObject class to write properties; Further: the get method of the processor AxObjectHandle object, the first parameter is recorded as target; it represents the interception object, and the second parameter is recorded as prop, which represents the interception object property or method name; Further: in the get method of the processor AxObjectHandle object, first determine whether the prop exists in the target object, and if so, directly return the prop attribute of the target object; otherwise, assign the AxObject_Invoke method process to the prop attribute of the target object and return the prop attribute of the target object; Preferably: in the AxObject_Invoke method, the target object Invoke method is called, wherein the prop attribute name is used as the first parameter of the target object Invoke method; the variable-length parameter of the AxObject_Invoke is used as the second parameter of the target object Invoke method; Preferably: in the AxObject_Invoke method, obtain the return value R3 of calling the target object Invoke method; determine whether the R3 data type is a Json object, if not, directly return the R3; otherwise, obtain the Dispatch interface identifier OID1, and use the OID1 to create a new AxObject object Ax1, use JavaScriptProxy to reconstruct the Ax1 object and the JavaScript Proxy's processor AxObjectHandle object into a new object proxy Proxy1, and return the Proxy1 object; Further: the set method of the processor AxObjectHandle object, the first parameter is recorded as target, indicating the interception object; the second parameter is recorded as prop, indicating the name of the interception object attribute; the third parameter is recorded as value, indicating setting the attribute value; Further: in the set method of the processor AxObjectHandle object, in order to distinguish it from the read property, the fixed mark Pre in step S2 is added before the prop property name to generate a new name propN. The target object Invoke method is called, wherein the propN is used as the first parameter of the target object Invoke method; and the value is used as the second parameter of the target object Invoke method.
[0018] S4: Create an ActiveX plug-in object and generate a Proxy proxy AxProxy object: The browser webpage remotely calls the plug-in container program interface through the Class ID or ProgID of the ActiveX plug-in to create a plug-in object, realize the creation of the ActiveX plug-in and return the ActiveX plug-in Dispatch interface identifier OID2; use the OID2 to create a new AxObject object Ax2, and use JavaScript Proxy to construct the ActiveX plug-in object proxy AxProxy with the Ax2 object and the JavaScript Proxy's processor AxObjectHandle object.
[0019] S5: using the AxProxy object to dynamically call the ActiveX plug-in interface, the ActiveX plug-in interface includes read properties, write properties and method functions; the JavaScript script uses the AxProxy object to call the ActiveX plug-in method and write property interface, which is consistent with the traditional JavaScript calling the browser plug-in object method and write property interface; the JavaScript script uses the AxProxy object to call the ActiveX plug-in read property interface, which is consistent with calling the ActiveX plug-in method interface; Specifically, when the JavaScript script calls the ActiveX plug-in object method Method1, the name of the method Method1 of the AxProxy object is consistent with the name of the ActiveX plug-in method Method1, and the method parameter params of the AxProxy object is consistent with the ActiveX plug-in method parameter, that is, AxProxy.Method1(params); Specifically, when the JavaScript script calls the ActiveX plug-in object to read the property Prop to obtain the value Value1, the method Prop name of the AxProxy object is consistent with the name of the ActiveX plug-in property Prop, and the method Prop of the proxy AxProxy has no parameters, that is, Value1 = AxProxy. Prop(); Specifically, when the JavaScript script calls the ActiveX plug-in object to write the property Prop to assign the value Value2: the name of the property Prop of the AxProxy object is consistent with the name of the property Prop of the ActiveX plug-in, that is, AxProxy.Prop = Value2; Specifically, when the ActiveX plug-in Method1 method interface returns as Dispatch interface Disp2, and Disp2 has method Method2, and the parameter is params2, the JavaScript script can be cascaded, that is, AxProxy.Method1(params).Method2(params2). Similarly, when the ActiveX plug-in Prop read property interface returns as Dispatch interface Disp3, and Disp3 has method Method2, and the parameter is params2, the JavaScript script can be cascaded, that is, AxProxy. Prop ().Method2(params2). BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a structural principle diagram of the present invention; Figure 2 is a flow chart of the method of the present invention; Figure 3 It is the AxObject class related code of the present invention; Figure 4 It is the code related to the processor AxObjectHandle object of the present invention; Figure 5 The JavaScript of the present invention creates the ActiveX plug-in Proxy object related code; Figure 6 The JavaScript of the present invention calls the ActiveX plug-in interface related code through the Proxy mode; Figure 7 It is a comparative summary of calling the ActiveX plug-in interface through the Proxy mode of the present invention and the traditional calling interface mode. Specific implementation methods
[0021] The specific implementation of the present invention will be further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.
[0022] See also Figure 1 The invention provides a structural principle diagram of a simple browser webpage loading an ActiveX plug-in through middleware technology.
[0023] See also Figure 2 The present invention provides a method for dynamically calling an ActiveX plug-in interface based on JavaScript Proxy, characterized in that it comprises the following steps: S1: defining a JavaScript class AxObject; S2: a plug-in container program calls the ActiveX plug-in interface and returns an interface execution result; S3: constructing a JavaScript Proxy processor AxObjectHandle object; S4: creating an ActiveX plug-in object and generating a Proxy agent AxProxy; S5: using the AxProxy object to dynamically call the ActiveX plug-in interface.
[0024] Specifically, the step S1 includes: the AxObject has an initialization method constructor for object initialization; an obj attribute for recording the Dispatch interface identifier; and an Invoke method for remotely calling the ActiveX plug-in Dispatch interface, such as Figure 3 As shown; Further: the Invoke method of the AxObject is a JavaScript indefinite length parameter method; Further: In the Invoke method of the AxObject, the first parameter of the arguments built-in object is the plug-in interface name N1; the rest are the plug-in interface parameter array Params; Further: in the Invoke method of the AxObject, each parameter param in the plug-in interface parameter array Params is traversed, and when the param type is object, it is replaced with the attribute obj value of the AxObject object, indicating the identifier of the corresponding plug-in Dispatch interface; Further: in the Invoke method of the AxObject, the interface call command CMD, the obj attribute of the AxObject class, the plug-in interface name N1, and the plug-in parameter array Params are packaged into Json data J1; Further: in the Invoke method of the AxObject, the Json data J1 is sent to the plug-in container program in step S2 through the network, the plug-in container program returns the plug-in interface execution result R1, the Invoke method of the AxObject parses the execution result R1, obtains the plug-in interface return value R2 and returns the return value R2, thereby realizing the remote call of the ActiveX plug-in Dispatch interface.
[0025] Specifically, the step S2 includes: the plug-in container program calls the ActiveX plug-in interface and returns the interface execution result: the plug-in container program parses the Json data J1 of the Invoke method of the AxObject object in step S1, and obtains the interface call command CMD and the obj attribute of the AxObject class, the plug-in interface name N1, and the plug-in parameter array Params information. According to the interface call command CMD, the ActiveX interface dynamic call module is called, and the corresponding ActiveX object Dispatch interface Disp1 is searched through the obj attribute of the AxObject class; according to the plug-in interface name N1, the interface ID of the method name N1 in the Dispatch interface Disp1 is obtained, recorded as DispID1; if the DispID1 is less than 0, it means that the interface does not exist, and the execution error code is returned; otherwise, all members of the parameter array Params are converted into variant variable type varParams; the DispID1 and the varParam are used as parameters to call the Invoke method of the Dispatch interface Disp1 to obtain the return value R2. Convert the return value R2 and the execution error code into a Json string, and return it to the Invoke method of the AxObject object in step S1; In particular, if the plug-in interface name N1 begins with a fixed mark Pre, indicating that the plug-in is called to write properties, before obtaining the interface ID of the Dispatch, the fixed mark Pre should be removed, the property name Prop should be obtained, and the plug-in object write property interface call can be implemented by calling the Disp1 object Invoke method; otherwise, the interface ID of the Dispatch interface Disp1 can be directly obtained, and the plug-in object read property or method interface call can be implemented by calling the Disp1 object Invoke method; In particular, if the return value R2 is a Dispatch interface, the plug-in container program should manage the Dispatch interface to facilitate subsequent calls to the Dispatch interface.
[0026] Specifically, the step S3 includes: constructing a processor AxObjectHandle object of JavaScript Proxy: implementing the get method of the processor AxObjectHandle object to intercept the call of the AxObject class to read properties and methods; implementing the set method of the processor AxObjectHandle object to intercept the call of the AxObject class to write properties, such as Figure 4 As shown; Further: the get method of the processor AxObjectHandle object, the first parameter is recorded as target; it represents the interception object, and the second parameter is recorded as prop, which represents the interception object property or method name; Further: in the get method of the processor AxObjectHandle object, first determine whether the prop exists in the target object, and if so, directly return the prop attribute of the target object; otherwise, assign the AxObject_Invoke method process to the prop attribute of the target object and return the prop attribute of the target object; Preferably: in the AxObject_Invoke method, the target object Invoke method is called, wherein the prop attribute name is used as the first parameter of the target object Invoke method; the variable-length parameter of the AxObject_Invoke is used as the second parameter of the target object Invoke method; Preferably: in the AxObject_Invoke method, obtain the return value R3 of calling the target object Invoke method; determine whether the R3 data type is a Json object, if not, directly return the R3; otherwise, obtain the Dispatch interface identifier OID1, and use the OID1 to create a new AxObject object Ax1, use JavaScriptProxy to reconstruct the Ax1 object and the JavaScript Proxy's processor AxObjectHandle object into a new object proxy Proxy1, and return the Proxy1 object; Further: the set method of the processor AxObjectHandle object, the first parameter is recorded as target, indicating the interception object; the second parameter is recorded as prop, indicating the name of the interception object attribute; the third parameter is recorded as value, indicating setting the attribute value; Further: in the set method of the processor AxObjectHandle object, in order to distinguish it from the read property, the fixed mark Pre in step S2 is added before the prop property name to generate a new name propN. The target object Invoke method is called, wherein the propN is used as the first parameter of the target object Invoke method; and the value is used as the second parameter of the target object Invoke method.
[0027] Specifically, the step S4 includes: creating an ActiveX plug-in object and generating a Proxy agent AxProxy: the browser webpage remotely calls the plug-in container program interface through the Class ID or ProgID of the ActiveX plug-in to create a plug-in object, realizes the creation of the ActiveX plug-in and returns the ActiveX plug-in Dispatch interface identifier OID2; uses the OID2 to create a new AxObject object Ax2, and uses JavaScript Proxy to construct the ActiveX plug-in object proxy AxProxy with the Ax2 object and the processor AxObjectHandle object of the JavaScript Proxy, such as Figure 5 shown.
[0028] Specifically, the step S5 includes: using the AxProxy object to dynamically call the ActiveX plug-in interface, the ActiveX plug-in interface includes read properties, write properties and method functions; the JavaScript script uses the AxProxy object to call the ActiveX plug-in method and write property interface in a manner consistent with the traditional JavaScript calling the browser plug-in object method and write property interface; the JavaScript script uses the AxProxy object to call the ActiveX plug-in read property interface in a manner consistent with calling the ActiveX plug-in method interface; Specifically, when the JavaScript script calls the ActiveX plug-in object method Method1, the name of the method Method1 of the AxProxy object is consistent with the name of the ActiveX plug-in method Method1, and the method parameter params of the AxProxy object is consistent with the ActiveX plug-in method parameter, that is, AxProxy.Method1(params); Specifically, when the JavaScript script calls the ActiveX plug-in object to read the property Prop to obtain the value Value1, the method Prop name of the AxProxy object is consistent with the name of the ActiveX plug-in property Prop, and the method Prop of the proxy AxProxy has no parameters, that is, Value1 = AxProxy. Prop(); Specifically, when the JavaScript script calls the ActiveX plug-in object to write the property Prop to assign the value Value2: the name of the property Prop of the AxProxy object is consistent with the name of the property Prop of the ActiveX plug-in, that is, AxProxy.Prop = Value2; Specifically, when the ActiveX plug-in Method1 method interface returns as Dispatch interface Disp2, and Disp2 has method Method2, and the parameter is params2, the JavaScript script can be cascaded, that is, AxProxy.Method1(params).Method2(params2). Similarly, when the ActiveX plug-in Prop read property interface returns as Dispatch interface Disp3, and Disp3 has method Method2, and the parameter is params2, the JavaScript script can be cascaded, that is, AxProxy. Prop ().Method2(params2).
Claims
1. A method for dynamically calling ActiveX control interface based on JavaScript Proxy, Features: The following steps are involved: S1: define a JavaScript class AxObject; S2: The plug-in container program calls the ActiveX plug-in interface and returns the interface execution result; S3: Build the JavaScript Proxy processor AxObjectHandle object; S4: Create an ActiveX plug-in object and generate a Proxy proxy AxProxy object; S5: Use the AxProxy object to dynamically call the ActiveX plug-in interface.
2. A method for dynamically calling an ActiveX control interface based on JavaScript Proxy according to claim 1, Features: In step S1, a JavaScript class AxObject is defined as the JavaScript proxy of the ActiveX plug-in Dispatch interface. The AxObject has an initialization method constructor for object initialization; an obj attribute for recording the Dispatch interface identifier; and an Invoke method for remotely calling the ActiveX plug-in Dispatch interface. The Invoke method of AxObject is characterized in that: the Invoke method is a JavaScript variable-length parameter method; the first parameter of the arguments built-in object is the plug-in interface name N1; the rest are the plug-in interface parameter array Paras; each parameter param in the parameter array Paras is traversed, and when the param type is object, it is replaced with the attribute obj value of the AxObject object, indicating the identifier of the corresponding plug-in Dispatch interface; the interface call command CMD and the obj attribute of the AxObject class, the plug-in interface name N1, and the plug-in parameter array Paras are packaged into Json data J1; the above-mentioned Json data J1 is sent to the plug-in container program in the step S2 through the network, and the plug-in container program returns the plug-in interface execution result R1, and the Invoke method of AxObject parses the execution result R1, obtains the plug-in interface return value R2 and returns the return value R2, so as to realize the remote call of the ActiveX plug-in Dispatch interface.
3. The method of dynamically calling an ActiveX control interface based on JavaScript Proxy according to claim 1, Features: In the step S2, the plug-in container program parses the Json data J1 of the Invoke method of the AxObject object in the step S1, and obtains the interface call command CMD and the obj property of the AxObject object, the plug-in interface name N1 and the plug-in parameter array Params information. According to the interface call command CMD, the Dispatch interface of the ActiveX plug-in is called: through the obj property of the above AxObject class, the Dispatch interface Disp1 corresponding to the ActiveX object is searched; according to the plug-in interface name N1, the interface ID of the method name N1 in the Dispatch interface Disp1 is obtained, recorded as DispID1; if the DispID1 is less than 0, it means that the plug-in interface name N1 does not exist, and an execution error code is returned; otherwise, all members of the parameter array Params are converted into variant variable type varParams; the DispID1 and the varParam are used as parameters to call the Invoke method of the Dispatch interface Disp1 to obtain the return value R2. Convert the return value R2 and the execution error code into a Json string J2, and send the Json string J2 to the Invoke method of the AxObject object in step S1 through the network; Its characteristics also include that if the plug-in interface name N1 starts with a fixed mark Pre, it means calling the ActiveX plug-in to write properties. Before obtaining the interface ID of the Dispatch, the fixed mark Pre should be removed, the property name Prop should be obtained, and the plug-in object write property interface call is implemented by calling the Disp1 interface Invoke method; otherwise, the interface ID of the Dispatch interface Disp1 can be directly obtained, and the plug-in object read property or method interface call can be implemented by calling the Disp1 interface Invoke method.
4. The method of dynamically calling an ActiveX control interface based on JavaScript Proxy according to claim 1, Features: In the step S3, a processor AxObjectHandle object of the JavaScript Proxy is constructed, including an implementation of a get method of the processor AxObjectHandle object and an implementation of a set method of the processor AxObjectHandle object; The implementation of the get method of the processor AxObjectHandle object, the first parameter of the get method is recorded as target; the second parameter is recorded as prop. First, determine whether the prop exists in the target object. If it exists, directly return the prop attribute of the target object; otherwise, assign the AxObject_Invoke method process to the prop attribute of the target object, and return the prop attribute of the target object; In the AxObject_Invoke method, the target object calls the Invoke method, wherein the prop name is used as the first parameter of the target object's Invoke method; the indefinite-length parameter of the AxObject_Invoke is used as the second parameter of the target object's Invoke method; the return value R3 of calling the target object's Invoke method is obtained; it is determined whether the R3 data type is a Json object, and if not, the R3 is directly returned; otherwise, the Dispatch interface identifier OID1 is obtained, and the OID1 is used to create a new AxObject object Ax1, and the Ax1 object and the JavaScript Proxy's processor AxObjectHandle object are rebuilt into a new object proxy Proxy1 using JavaScript Proxy, and the Proxy1 object is returned; The implementation of the set method of the processor AxObjectHandle object is characterized in that: the first parameter of the set method is recorded as target; the second parameter is recorded as prop; and the third parameter is recorded as value. In order to distinguish it from the read attribute, the fixed mark Pre in step S2 is added before the prop attribute name to generate a new name propN. The target object Invoke method is called, wherein propN is used as the first parameter of the target object Invoke method; and value is used as the second parameter of the target object Invoke method.
5. The method of dynamically calling an ActiveX control interface based on JavaScript Proxy according to claim 1, Features: In the step S4, an ActiveX plug-in object is created and a Proxy proxy AxProxy object is generated. The browser webpage remotely calls the plug-in container program interface through the Class ID or ProgID of the ActiveX plug-in to create the ActiveX plug-in object, realizes the creation of the ActiveX plug-in and returns the ActiveX plug-in Dispatch interface identifier OID2; uses the OID2 to create a new AxObject object Ax2, and uses JavaScript Proxy to construct the ActiveX plug-in object proxy AxProxy with the Ax2 object and the processor AxObjectHandle object of the JavaScript Proxy.
6. The method of dynamically calling an ActiveX control interface based on JavaScript Proxy according to claim 1, Features: In step S5, the AxProxy object is used to dynamically call the ActiveX plug-in interface, and the ActiveX plug-in interface includes read properties, write properties and methods; when the JavaScript script calls the ActiveX plug-in object method Method1, the name of the method Method1 of the AxProxy object is consistent with the name of the ActiveX plug-in method Method1, and the method parameter params of the AxProxy object is consistent with the method parameter of the ActiveX plug-in, that is, AxProxy.Method1(params); when the JavaScript script calls the ActiveX plug-in object to read the property Prop to obtain the value Value1, the method Prop name of the AxProxy object is consistent with the name of the ActiveX plug-in property Prop, and the method Prop of the AxProxy object has no parameters, that is, Value1 = AxProxy.Prop(); when the JavaScript script calls the ActiveX plug-in object to write the property Prop to assign the value Value2: the property Prop name of the AxProxy object is consistent with the name of the ActiveX plug-in property Prop, that is, AxProxy.Prop = Value2.
