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

InprocServer32

· 52CE 我爱测

Registers a 32-bit in-process server and specifies the threading model of the apartment the server can run in.

Registers a 32-bit in-process server and specifies the threading model of the apartment the server can run in.

Registry Entry

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID
   {CLSID}
      InprocServer32
         (Default) = path
         ThreadingModel = value

Remarks

ThreadingModel is a REG_SZ value the specifies the threading model. The possible values are shown in the following table.

Value Description
Apartment Single-threaded apartment
Both Single-threaded or multithreaded apartment
Free Multithreaded apartment
Neutral Neutral apartment

You must use the same value for every object provided by the in-process server.

If ThreadingModel is not present or is not set to a value, the server is loaded into the first apartment that was initialized in the process. This apartment is sometimes referred to as the main single-threaded apartment (STA). If the first STA in a process is initialized by COM, rather than by an explicit call to CoInitialize or CoInitializeEx, it is called the host STA. For example, COM creates a host STA if an in-process server to be loaded requires an STA but there is currently no STA in the process.

Whenever possible, the in-process server is loaded in the same apartment as the client that loads it. If the threading model of the client apartment is not compatible with the model specified, the server is loaded as indicated in the following table.

Threading model of server Apartment server is run in
<\not specified> Main STA
Both Same apartment as client
Free Multithreaded apartment
Neutral Neutral apartment

If the threading model of the server is Apartment, the apartment the server is loaded in depends on the apartment the client is running in, as indicated in the following table.

Apartment client is run in Apartment server is run in
Multithreaded Host STA
Neutral (on STA thread) Same apartment as client
Neutral (on MTA thread) Host STA

COM can also create a host multithreaded apartment (MTA). If a client in a single-threaded apartment requests an in-process server whose threading model is Free when there is no MTA in the process, COM creates a host MTA and loads the server into it.

For a 32-bit in-process server, the InprocHandler32, InprocServer, InprocServer32, and Insertable keys must be registered. The InprocServer entry is needed only for backward compatibility. If it is missing, the class still works but it cannot be loaded in 16-bit applications.

If a container is searching the registry for an in-process server, the 16-bit version has priority with a 16-bit container and the 32-bit version has priority with a 32-bit container.

Related topics

InprocServer

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)

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

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