The customer calls the COM Process and calls the com process.

Source: Internet
Author: User

The customer calls the COM Process and calls the com process.

Reference: COM technical insider

DllGetClassObject
Https://msdn.microsoft.com/en-us/library/windows/desktop/ms680760.aspx
If a call to the CoGetClassObject function finds the class object that is to be loaded in a DLL,
CoGetClassObject uses the DLL's exported DllGetClassObject function.

IClassFactory
Https://msdn.microsoft.com/en-us/library/windows/desktop/ms694364.aspx
After calling the CoGetClassObject function to get an IClassFactory interface pointer to the class object,
Call the CreateInstance method of this interface to create an object.

CoCreateInstance
Https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615.aspx
CoCreateInstance is equivalent
{
CoGetClassObject (rclsid, dwClsContext, NULL, IID_IClassFactory, & pCF );
Hresult = pCF-> CreateInstance (pUnkOuter, riid, ppvObj
PCF-> Release ();
}

CoGetClassObject: searches for the specified component in the registry. After finding it, it will load the DLL that implements this component.
After successful loading, it will call the DllGetClassObject implemented in the DLL server.
DllGetClassObject: This function is used to create a response class field.
Query the IClassFactory interface and return it to CoCreateInstance.
CoCreateInstance will use this interface to call the IClassFactory: CreateInstance Function
IClassFactory: CreateInstance calls the new operator to create a specified component and query the component's IX interface.

// The customer calls the COM process:
CoCreateInstace (rclsid, NULL, dwClsContext, IID_IX, (void **) & pIX); // IX * pIX
| --> CoGetClassObject (rclsid, dwClsContext, NULL, IID_IClassFactory, & pCF) // IClassFactory * pCF
| --> DllGetClassObject (rclsid, IID_IClassFactory, & pCF)
| --> CFactory * pFactory = new CFactory ();
| --> PFactory-> QueryInterface (IID_IClassFactory, & pCF); // return class field pointer IClassFactory * pCF
| --> PCF-> CreateInstance (pUnkOuter, IID_IX, & pIX); // IX * pIX component interface pointer pIX
PIX-> Fx ();

 

Note:. def module definition file

LIBRARY "ComComponent"

EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

Related Article

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.