[New romantic architecture original] Robin and you learn com
Original address: http://charming.vicp.net/cgi-bin/topic.cgi? Forum = 5 & Topic = 2139 slide address: http://charming.vicp.net/download/comstudy.htm Forum Address: http: / /charming.vicp.net/cgi-bin new romantic architecture: http://charming.vicp.net
I believe that many similar to learning and programming are very difficult to see it, I hope to give you the direction.
COM = component object model.
In Windows, the COM component needs to exist in the .dll or .exe file, these files are their carrier. So you can know that there is any COM component in .dll, .exe, you can have any COM components. For the process, these concepts are not the main concept of COM, I don't talk.
Each COM component can also contain several objects that can be objects that implement objects or are always objects that can be upgraded (an object is a package that can implement a specific function code data package), if an object The function is not intended to be upgraded again, you can implement functionality directly, if not, better than Word.9 Word.10, etc., the object's function will be upgraded, then you can let the program that access to this object Access an interface And this interface can know the upgraded object implementation code. (The interface is in your own components, so it should and must know the actual address of the specific version of the object)
Look at this picture
1 I want to send an email ------> [call send email function] (here the function is complete, you can never change)
2 I want to send an email -----> [call send email function interface -> version 1] ...................... [.. ...................... | -> version 2] ...................... [........................ | -> version 3] ................... ... [...................................... ...... [.......................... | -> Version 5]
The difference between COM components and C objects is that the C object is loaded directly into the memory, before running, there is no object. C object does not tell others where it is, she finds a piece of address in memory, then there, waiting for the programmer who creates this object to write. If someone trying to call this object, you must find the address of the object, but it is impossible to find it, no one knows where.
The object in the COM component is present in the .dll, .exe file, it is in the computer in binary form. Other programmers trying to call the object can use the COM running environment to load this .dll, .exe file to the memory, then the component object will tell the COM operating environment. (To use the COM component function, the operating system must be able to run the COM running environment, this thing is a casing, running the COM object in memory in the memory, this running environment is loaded into memory before using the COM object, itself Also .dll file)
Look at this picture: Customer program <---> COM running Environment <-> COM object in memory.
See the difference between and C objects? COM component objects are in memory, tell COM to run some of its information, such as 1 address IUNKNOWN interface tells individual objects, functions, and port addresses. 2 The number of visited, when this is 0, the COM run environment can choose to destroy this object from memory from memory at some time.
Here is a key message, which is a different function COM object, you can choose to tell the COM to run different information, how much you can decide yourself, but if you want to be a more advanced COM object, such as ActiveX control, such as a COM object, such as DCOM object , Such as automation objects
As for how to tell COM running environment, it is said in advance, you must provide information in these interfaces, these pre-saying things will join the COM component specification. For example: iDispatch provides automation information.