CLSCTX
CLSCTX is a Windows COM (Component Object Model) enumeration used to specify the context in which a COM object should be created or a class object should be retrieved. It is passed to creation APIs such as CoCreateInstance and CoGetClassObject to indicate where the server code should run and how it should be loaded. CLSCTX values are bit flags and can be combined to express multiple acceptable contexts. The flags influence whether code runs in-process within the caller, in a separate local process, or on a remote machine, and they can also request the bitness of the server in cross-bitness scenarios.
- CLSCTX_INPROC_SERVER: The object is implemented as a DLL loaded into the caller’s process (in-process server).
- CLSCTX_INPROC_HANDLER: The object runs in the caller’s process as an in-process handler, typically used for proxies
- CLSCTX_LOCAL_SERVER: The object is implemented by a local executable (EXE) and runs as a separate process
- CLSCTX_REMOTE_SERVER: The object runs in a COM server on a remote machine.
- CLSCTX_SERVER: A convenience flag combining in-process and local server contexts.
- CLSCTX_ALL: Requests all possible contexts (in-proc, local, and remote).
Optional activation flags include:
- CLSCTX_ACTIVATE_32_BIT_SERVER: Request a 32-bit server in cross-bitness environments.
- CLSCTX_ACTIVATE_64_BIT_SERVER: Request a 64-bit server in cross-bitness environments.
Usage notes: The chosen context affects performance, security, and compatibility. If a requested context is unavailable