Advanced COM techniques in the ActiveX Pack1
List of the classes in this section:
(from version 184.108.40.206) - Run scripts in separate thread
- Advanced COM object creation techniques: Create the
objects from ActiveX pack1 library directly bypassing the system
(faster and possible without registering the DLL), Create
composite objects, create COM objects from COM DLL that are not
registered with the system etc.
Make calls to objects in separate thread.
- Maintain COM apartment and create/hold there COM
ActiveX Pack1 contains several objects that allow the scripting
applications (such as ASP pages for example) to do things
otherwise available for C++/VB/Delphi applications only. And even
in these environments it will require additional efforts. Sometimes
the limitations of the host of the application (such as IIS or
ALP) limits the usage of certain components or techniques. For
example an ASP application running under ALP may want to index the
hard disk. Such task will take considerable time and is not
suitable for an ASP page (no one will wait 15+ minutes for a page
to complete). So one of the logical ideas are the threads - run
some separate script to do the task in a separate thread and may
be allow the user to check its progress from time to time while he
is still able to use the other parts of the application. Another
not so obvious problem are the COM
apartments. In case of pure
autorun implemented with ALP you may want to use components not
registered with the system. As the COM API depends on the system
registry for the determination of the required threading model for
a particular component in such a scenario they all will be created
in the same apartment where ALP runs (a free threaded apartment).
This may cause certain components to fail and here comes the
ActiveX pack1 COMApartment object. Even the previous example - the
thread most often needs a separate COM apartment because the COM
synchronization may prevent the thread to actually run.
Aside of the features mentioned above the application may need
sometimes non-standard way to create a COM object (directly
specifying the DLL and the ClassID in it for example) etc. The
ActiveX pack1 now contains tools for each of these situations and
the developer have the opportunity to do things not possible for
the script based applications before.
Do you need to know something more if you want to use these
components? Some of the tricks can be done following the samples
but a bit more knowledge about COM and the product you use (ALP,IIS
etc) will help you go beyond the samples and do whatever you need,
implement ideas you considered impossible before. We suggest
reading the COM apartments and threads chapter where you will find
basic information about them and how the hosts use them.