大网数据广告活动
Windows 系统接口

Implementing IClassFactory

· 52CE 我爱测

When a client uses a CLSID to request the creation of an object instance, the first step is creation of a class object, an intermediate object that contains an implementation of the methods of the IClassFactory interface. While COM provides several instance creation functions, the first step in the implementation of these functions is the creation of a…

When a client uses a CLSID to request the creation of an object instance, the first step is creation of a class object, an intermediate object that contains an implementation of the methods of the IClassFactory interface. While COM provides several instance creation functions, the first step in the implementation of these functions is the creation of a class object.

As a result, all servers must implement the methods of the IClassFactory interface, which contains two methods:

  • CreateInstance. This method must create an uninitialized instance of the object and return a pointer to a requested interface on the object.
  • LockServer. This method just increments the reference count on the class object to ensure that the server stays in memory and does not shut down before the client is ready for it to do so.

To enable a server to be responsible for its own licensing, COM defines IClassFactory2, which inherits its definition from IClassFactory. Thus, a server implementing IClassFactory2 must, by definition, implement the methods of IClassFactory.

COM also provides helper functions for implementing out-of-process servers. For more information, see Out-of-Process Server Implementation Helpers.

Related topics

COM Server Responsibilities

Licensing and IClassFactory2

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。