Haha, the network speed is very fast this evening. I usually get used to staring at the progress bar in the lower left corner of the browser. Today, I saw it as a dumb, and it came to my head, it's just a word. It's just tonight that I will continue my trip to COM.
Today, I want to talk about COM. Starting from how to implement a basic COM framework, we feel that COM brings us convenience and the art and charm of programming.
I stated in advance that the following points are my own ideas and do not have a reliable theoretical basis. I just want to remember such a complicated structure in the simplest way. So some examples may not be very appropriate, but I think they are suitable for me.
I still remember when I first got the "VC6 technology insider", it was an example of a ship. One of them was an IUNKNOW. I was so hard to find it, why do I want to learn about COM? For me, it is because I want to develop DirectShow. There is no way. It is based on COM. Although I will use it to write programs and implement some functions, but I still don't understand what the QueryInterface () functions seem Omnipotent do? I just know that I first use CreateInstance to create an instance and then use its QueryInterface () to get some pointers that look like objects, and then use these pointers-> call some functions to complete some functions. I know so much, but I have made a program that can run, in addition, you can display the captured images from the camera. This is a bit unimaginable to me. The entire DirectShow is like a black box for me, I just added a tag to each of the ports that I gave to me to show what the items in them were doing. So I reached out and took them out, after I put it together, I finished my work. It's a bit like a lamp, huh, it's amazing, isn't it? I think so too, which leads to the essence of our COM. We can provide a simple access method to complete various actions, and users do not need to deal with these details at all, you only need to select the corresponding function based on the description (TAG) to achieve your goal. I think it is better to call it a component to make its parts more vivid. Another advantage is reuse!
How can we create such a part on our own? Don't rush together. Take it easy. If we have learned C ++, we will naturally consider the problem with object-oriented thinking, naturally, parts are abstracted into a class for implementation. Yes? Yes, but it is not the only method. I will not extend it here. If you are interested, you can check it yourself. As a class to implement it, there is a natural benefit, that is, inheritance, our parts are universal parts and can be customized. For different application scenarios, we can also perform lossless secondary development for the parts to be reflected in C ++, the original parts become the parent class (the base class), and the new secondary development of the parts become the Child class (the inheritance class). In this way, it not only inherits everything from the original, you can also add new features.
Another concept should be clear: Classes in C ++ can directly operate and use instance data, but the COM component will never directly access any instance data, but access is implemented through functions. This is also intended for greater flexibility.
So from the above, we need to first define a basic and general part model so that we can expand it in the future, and this basic model, the IUNKNOWN interface that I want to talk about today.
The interface mentioned here is the one mentioned above, which provides access portals. All other interfaces are inherited from it,
(Unfinished)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service