SpData. GetPropertyByName (Lstr, & varValue2 );
The two attributes of the Object returned by JS are result and str, which are an integer data and a string respectively.
Here, the JS Code is written by ourselves. On the VC side, of course, we know that the objects returned by this JS function have the attributes "result" and "str.
What should I do if the JS Code is not written by us or its attributes are uncertain in advance? The answer is to use the IDispatchEx interface to enumerate related information (method name and attribute name) of this object ).
I will not talk about this for the time being, but will talk about it in subsequent articles.
Of course, JS can not only return Object objects, but also return any objects. when an Object is returned rather than the basic data type (integer, floating point, string, the return value received by VC is an IDispatch. Then, we need to call the GetPropertyByName method to retrieve its attributes from the Objects represented by this IDispatch.
In this way, VC calls the JS function and passes the parameters to JS and JS to return the return value to VC, which will be roughly the same.
If you are not familiar with the smart variable VARIANT packaged by CComVariant, you can view relevant information online. In-depth analysis of ATL and other books are introduced.
It is worth noting that the smart packaging classes starting with CCom provided by ATL do not depend on the dynamic library of ATL. Because I didn't select the link to ATL in the VC project, there were no modules such as ATL100.dll loaded during program debugging. You can use it without worrying about relying on ATL.
VC can call JS functions. So how do JS functions call VC? We will try again later in the next article.