Version 56 of COM

Updated 2007-02-16 15:16:15

Microsoft's Component Object Model [L1 ] ... Wikipedia, as usual, has a valuable (if incomplete) article [L2 ] on the subject.


(COM: Some people associate DOS-style serial-line devices with this. Information about that is on this page: Serial Ports on Windows.)



TclScript also is COM-aware.


COMet is a COM Explorer for Tcl. It's a tcom based application to discover and interactively program COM objects.


Many popular Microsoft Windows applications expose a COM automation [L3 ] interface, which allows external programs to launch and control them. 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

How do I find out which COM objects are available?

In this c.l.t. posting [L4 ], 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
     }
 }

[Explain relation between COM and WSH.]


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."



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 module [L5 ] executable in Python contexts. 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.


[Explain PT's new "Structured Storage" stuff--important. http://www.patthoyts.tk/index.html#tclstorage Pat also has an "OLE Application automation" [L6 ] ]


At various times, steveo, stever, CL, and others have worked on DCOM.



Category Acronym - Category Windows