C U T B H P N

Lecture #11 - COM Apartment Model

Isolation

Web Resources:

Linux Tutorials eclipse Code Project SysInternals Best SysInternals Tools Dr. Dobb's Journal Windows Forms COM at MSDN IDL Language base MIDL types OLE data types IDL attributes MIDL data types MIDL Language Reference

Content:

In this lecture we discuss COM Apartments.

  1. Syllabus describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Project #1, Project1HelpS19
  3. Project #1 Prototype
    This demo has a client, a using component, and a used component. The client creates both used and using components, then passes a pointer to used to the using to set up that communication. This structure would work fine for Project #1, where the used component is FileMgr and the using component is the TextSearch component. This was supposed to be a simple demonstration of how to use the ATL wizards. Unfortunately they are broken in Visual Studio 2017. To do the demonstration, I installed VS 2015 to carry out the demo. I then loaded that project into Visual Studio 2017 to execute and demonstrate the communication patterns between client, used, and using components.
  4. You will find in the CSE775/Code/Project1HelpS19, a demonstration of FileSystem, a package of file, path, and directory operations implemented with classes:
    • Block and File
    • FileInfo
    • Path
    • Directory
    I modeled the design of these after the excellent System.IO classes of the same names in the .Net library. There are versions for both Windows and Linux.
  5. Thread Locking Performance
    Testing C++11 synchronization performance
    How does C++11 synchronization performance compare to Win32 synchronization?
  6. Technology Presentations
  7. Building COM Projects
  8. Connection Points:

    Connectable Objects
    Introduction to Connection Points.
    ATLProject1_Helper
    Demonstrates building a simple component with connection point callbacks and both C++ and C# clients. Late Binding, ppt Late Binding COM Events, ppt
  9. Out-of-Process COM Components

    OutProc Presentation OutProc Class Diagram, OutProc Sequence Diagram
    OutProc ST Structure Chart, OutProc MT Structure Chart IDL Demo - Interfac
    We looked at this before. It's here as a reminder that all the interface method parameters were being marshalled between the client and component processes. Raw C++ Out-of-Process Single-Threaded Apartment Component
    We will go through this code carefully so you see the structure of an out-of-proc COM component. Raw C++ Out-of-Process Multi-Threaded Apartment Component
    We will make a quick comparison of this with the previous code so you see the differences between ST and MT code. ATL Out-of-Process Single-Threaded Apartment Component
    This is the ATL-based version of the OutProcST project. OutProc with console
    Out-of-Process components have no visible interface unless you add one. This demonstrates how to add a console. OutProc with dialog
    Out-of-Process components have no visible interface unless you add one. This demonstrates how to add a dialog.
  10. COM Apartments

    COM overview - Review - MSDN Processes, Threads, and Apartments - MSDN COM Apartments Presentation Thread Rules Understanding COM Apartments, Part I - Jeff Prosise, Understanding COM Apartments, Part II - Jeff Prosise Eight Lessons from the COM school of Hard Knocks Marshaling Interface Pointers between Client Threads
    You can't pass interface pointers between apartments witout marshaling. To do so breaks the COM threading model. This project shows you how to do that marshaling. Component calls component
    This project demonstrates how to marshal an interface pointer through a COM interface. Look at the IDL for the OutterComp. You will see it pass an interface pointer to the InnerComp back to the client. The inner component is created by the outter component, but at the end the client needs to access the inner component to get its state information, so the client just uses the returned (marshaled) interface pointer for that.
  11. Distributed COM: and COM+

  12. Other COM Topics:

    Windows Template Library (WTL)
    Thin windows library created by ATL team. Structured Storage
    Demonstration of Structured Storage, e.g., file system in a file. Speech API
    Quick demo of Speech API - built with COM. Accessing Registry
    Programming the Registry (no guarantee it's bug free - buyer beware) Monikers
    Monikers are COM links between other COM objects and files, etc. Marshaling COM Pointers in Stream
    Demonstrates marshaling a COM pointer between Apartments using streams. COM Persistance
    Quick demo of COM persistance. Automation with IDispatch
    Demonstates use of Automation with a raw C++ IDispatch implementation. Demo ActiveX Control
    Demonstrates a simple composite ActiveX Control running in a web page.
  13. JavaScript and Go

  14. RESTful Web Services

CST strip