4.5. Creating ActiveX Components

In the Professional and Enterprise editions of Visual Basic, you can use class modules to create ActiveX components and compile them as either ActiveX DLLs or ActiveX EXEs. The choice you are faced with, effectively, is whether you require an in-process or an out-of-process component.

4.5.1. In-Process Components

An ActiveX DLL is an in-process component. But why is it called "in-process"?

In 16-bit Windows, a DLL effectively became part of the operating system, and all running processes had access to the DLL. A handle to the DLL could be obtained centrally from the operating system, and the operating system knew at any given time how many (if any) handles to a particular DLL had been issued. In 32-bit Windows, a DLL doesn't become part of the operating system. It becomes part of the process space of the application that calls the DLL. A call to a DLL forces the operating system to create a file mapping object for the DLL. This object is then mapped into the process space of the client or calling process. Hence the term in process.

4.5.2. Out-of-Process Components

When you create an ActiveX EXE, you are creating an out-of-process component. An ActiveX EXE runs as a separate process with its own threads. This is ideal for cases in which multiple applications (or multiple clients) are likely to require the functionality offered by the classes included in the ActiveX EXE. Moreover, an ActiveX EXE need not reside on the same system as its client; ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.