[Microsoft]'s '''[http://www.microsoft.com/com/%|%Component Object Model]''', or '''COM''', a component of [Microsoft Windows%|%Windows], enables software components to communicate. ** Disambiguation ** [Serial Ports on Windows]: [MS-DOS]-style serial-line devices are also called COM ports ** Description ** Many popular [Microsoft Windows%|%Windows] applications expose a [http://msdn.microsoft.com/en-us/library/windows/desktop/aa367809%28v=vs.85%29.aspx%|%COM automation interface], which allows external programs to launch and control them. Alex Martelli: "COM-related technologies seem mostly pretty good, except for the little detail that they're often huge, rambling, and full of redundancies and pitfalls -- this goes for the object model of WMI just as well as for those of MS Office applications." At various times, [steveo], [stever], [CL], and others have worked on [DCOM]. [[Explain relation between COM and [WSH].]] ** Example: ProgID ** The starting point to an application's COM automation interface is through its programmatic identifier (ProgID). Here are a few example ProgID's, any of which might be used in, for instance, [tcom] with ====== set application [::tcom::ref createobject $ProgID] Netscape.Network.1 [http://developer.netscape.com/docs/manuals/communicator/OLE/ole2net.htm] FrontPage.Editor.Document Word.Document (note that WordPad is ''not'' a COM server) InternetExplorer.Application Excel.Application Excel.Application.8 PDF.PdfCtrl.1 Word.Application DSOleFile.PropertyReader ====== ** Finding Available COM Objects ** In [http://groups.google.com/d/msg/comp.lang.tcl/Q_-Schxqh5U/MMTjeIJNbgQJ%|%How do you find all ActiveX servers?], [comp.lang.tcl], 2001-10-19, [Chin Huang] provides the following code to search the Windows registry for available COM objects, and prints their ProgID: ====== package require registry set classesRootKey "HKEY_CLASSES_ROOT\\CLSID" foreach clsid [registry keys $classesRootKey] { set clsidKey "$classesRootKey\\$clsid" set progIdSubKey [registry keys $clsidKey "VersionIndependentProgID"] if {[llength $progIdSubKey] > 0} { set progId [registry get "$clsidKey\\$progIdSubKey" ""] puts $progId } } ====== ** COM Constants ** One of the eternal puzzles of COM work is how to find the right constants. Mark Hammond packaged up his insight on COM's constants into a [Python] module called [http://docs.activestate.com/activepython/2.7/pywin32/html/com/win32com/HTML/QuickStartClientCom.html#UsingComConstants%|%win32com.clients.constants]. Presumably we could, given enough motivation, do the same for Tcl, or at least render the code into human-readable direction. The section titled '''How to Obtain Built-In Constant Values for an Office Application''' on the page [How one discovers the API for a COM-exporting application] explains how to do this using [tcom]. ** Structured Storage ** COM [http://msdn.microsoft.com/en-us/library/windows/desktop/aa380369%28v=vs.85%29.aspx%|%Structured Storage] provides file and data persistence in COM by handling a single file as a structured collection of objects known as storages and streams. [Pat Thoyts]' [http://www.patthoyts.tk/tclstorage/%|%tclstorage] provides access to Structured Storage from Tcl. Pat also has an "OLE Application automation" [http://www.patthoyts.tk/index.html#autonotepad] ** See Also ** [http://en.wikipedia.org/wiki/Component_object_model%|%Wikipedia]: [http://www.magicsplat.com/book/com.html%|%COM chapter]: from [BOOK Tcl Programming for Windows] [TclScript]: COM-aware [COMet]: a COM Explorer for Tcl, which relies on [tcom], facilities discovery and interactive programming of COM objects. [COM Tree]: another COM inspector [COM Events]: [COM gateway extension]: [COM on! - a tiny web browser]: [COSH]: [OLE Object Viewer]: [optcl]: Another Tcl interface to COM [TclBridge]: allows [Tcl] to call COM objects and vice-versa. Very powerful, lots of options. [tcom]: included in recent [ActiveTcl] releases, offers both client and server COM functionality. [TWAPI COM support]: describes [TWAPI]'s client side COM capabilities. <> Glossary | Windows | COM