Some knowledge about using DLL in COM

Source: Internet
Author: User
We know that a feature of COM is dynamic link, and dynamic link is implemented by DLL in windows. Why can I use DLL to implement components? The reason is that dll can share the applications linked to them. Program .

Customers and components interact through interfaces. An interface is a pointer list (vtbl) pointing to the function pointer. The component allocates memory for vtbl and initializes this table with the address of each function. To use vtbl, the customer should be able to access the memory allocated by the component for its vtbl. At the same time, it must be able to understand the addresses of components placed in vtbl. In Windows, because the DLL and the customer use the same address space, there is no problem in accessing this vtbl.

When a customer obtains an interface pointer of a component, the only intermediary connecting the customer and component is the binary structure of the interface. When a customer queries the interface of a component, what it requests is actually a piece of memory with a specific format. When the component returns an interface pointer, it tells the customer that it is actually the address of the block memory.

------------------------------------------------
More than DLL
------------------------------------------------

About IID, UUID, CLSID

When Microsoft designed the specifications, there were two options to ensure that the user-designed components could be globally unique. The first was to set up a management organization using the same management method as the address, if you want to develop a component, you need to apply to the organization and pay a certain fee. The second is the inventionAlgorithmEach time, a component identifier can be generated. Obviously, the first method is too inconvenient for users. Therefore, Microsoft adopts the second method and invented an algorithm to identify components, it is a 128-bit long number, which is generally expressed in hexadecimal notation. The core idea of an algorithm is to combine the machine's Nic, local time, and a random number. Theoretically, if one machine generates 10000000 machines per second, it can be guaranteed (in probability) That 3240 will not be repeated.

The following is an example of a guid:

{54bf6567--1007--11d1--b0aa--444553540000}

In Microsoft's com, GUID is the same as UUID, CLSID, and IID, but their meanings are different:
UUID: COM Component
CLSID: indicates the class in the COM component.
IID: indicates the interface in the COM component.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.