"COM technology insider" FAQ

zhaozj2021-02-08  431

"COM technology insider" FAQ

Sunshineor@msn.com

Reading questions 1:

Chapter 11, Distribute Interface & Automation P231

"Automation in many different aspects of code written by developers instead of the code generated by the compiler"

How do this sentence understand?

answer:

There is no problem with this sentence:

Big intending is to say, the application we wrote, is the source level, you need to compile compile, in order to perform, now use the scripting language to operate the automation interface, you can dynamically complete the same application (actually interpretation).

A simple example, you definitely don't have a word source code. If you use Word to generate a use of the application of the specific application (in all ways to say government official documents), you can only find the source company to modify the source code to adapt to you. special needs. (Microsoft listened to you?)

However, you can customize your specific application with an automated interface, and use the VBA script to control the Word's automation interface. Yes, explanation is slow, but don't have to change source for you, don't have to test the source part of your modified source, isn't it better?

Reading questions 2:

Chapter 11, Distributing Interface & Automation P234

If the C programmer wants to construct a VTBL from the beginning while running, he can fully decide how to construct it. on the other hand..."

How should this pass?

answer:

Yes, a VTBLE generation is done by your compiler, but if you understand the constructor of the VTBL, you can imitate one out.

Suggestion Read: COM Nature Inside C Object Model

Have a good psychological preparation, hard bones

Reading questions 3:

What is the difference between oleinitialize in the Coinitialize (ex) these two functions?

P236 countdown sixth line has the call to Oleinitialize

answer:

Coinitialize CoinitializeEx is used to initialize the COM running environment, just like the people who practice martial arts first scratch a circle before practicing Wu, put the weapon in the circle ()

Oleinitialize is an initialization OLE's operating environment. OLE is an extension based on the basis of COM, which is the basis of ActiveX. It is the same as a steel wire in the circle, and the performance on the wire is performed.

Four of reading questions:

P208: About the explanation of the Point_Default keyword, do not understand)

1. "Point_Default keyword is to tell the MIDL compiler how to handle this pointer when specifying other properties for the pointer," Other Properties "?

2. "In the function, you can't specify an alias for them, what is an alias?

answer:

As for alias, it refers to the typedef bar in the MIDL language (I am very sorry, I don't have much attention to COM's scheduling section. I can only answer, please tell me after you have a clear answer).

Five of reading questions:

P234 The last sentence: "Of course, use the COM interface to implement IDispatch :: Invoke is also possible, please refer to Figure 11-2."

1. How to implement Invoke with a COM interface?

2. Figure 11-2 In FOOBAR is not a COM interface (there is no IUNKNOWN that three functions).

answer:

COM is better C . The implementation of COM is actually drawing on many C implementations. For example, take the VTBL mentioned earlier, according to the regulations, I don't think we should call the foobar of Figure 11-2 as a COM interface, but In the broad range, because of the use of VTBL, you can barely believe that he is also a COM interface, (if the author is going to talk about this, ^ _ ^)

Reading questions:

The distribution interface is a COM interface (in line with the definition of the COM interface)? Is it the relationship with the Invoke function? If it is not a COM interface, what is the definition of the distribution interface?

answer:

The distribution interface can be a COM interface, or not, this is just different ways, the distribution interface is a concept, and the interior should contain two arrays, a value of the DISPID and the interface method name (Pair), a stored Is the value of the DISPID and the interface method (that is, the function pointer). As long as there are two parts, we think it is a distribution interface, as for the COM interface, it doesn't matter.

Invoke, you need to provide DISPID and the corresponding parameters so that you can use the specific implementation mechanism of the distribution interface to get the function pointer to function call.

Reading questions:

P234 Chapter VI: "Idispatch :: INVOKE is implemented as a distribution interface, and DISPINTERFACE". Invoke is a function, how can I achieve "function set"?

What is the relationship between the INVOKE function and the distribution interface?

For idispatch :: Invoke, we can look at its running process

Before calling Invoke, we got a DISPID in a variety of ways (don't think that only getidsofNames can be obtained, I have implemented the DISPID that will be executed according to the status of different dynamics, and then provide in the component A method, ExecuteCmd (Dispid), so the client program can also dynamically perform the interface method of the component). The nature of the interface is an array of a set of function pointers, and Dispid is an index of the function pointer array (note that only the IDispatch interface is DISPID). By specifying the index, we can get the specified function pointer so we can use (* functions The way the pointer) (parameters, parameters ...) is modified.

"Wait," I heard you is shouting. "Our parameters are passed in the form of an array, and when you call the function pointer, it is called by the parameter list. How do I achieve it?"

Yes, if you want to write an invoke implementation, the stack and type processing of the light parameters will be exhausted, tell you a good way, use the MS API function (DispCallFunc or Dispinvoke, or use MFC / ATL's encapsulation implemented by Idispatch (MFC is a helper, and ATL uses iDispatchImpl template)

Distribution interface is a logical concept, which means that there is a pointer to the function method name and function. With this interface, you can retrieve the pointer of the function with the specified method name, the biggest use, is to provide a scripting interpreter use.

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

New Post(0)