Howto find com object enums for tcom using registry

This page provides an example of how to find enumerations/constants of Microsoft com objects the registry package for use of the tcom package.

Alexander Schöpe


Find Microsoft Outlook type library:

 package require registry
 package require tcom

 set application Outlook.Application

 if {[catch {registry get HKEY_CLASSES_ROOT\\$application\\CLSID {}} clsid]} {
   puts stderr "registry: $clsid"
   exit 1
 }
 if {[catch {registry get HKEY_CLASSES_ROOT\\CLSID\\$clsid\\Typelib {}} typelib]} {
   puts stderr "registry: $typelib"
   exit 1
 }
 if {[catch {registry keys HKEY_CLASSES_ROOT\\TypeLib\\$typelib} keys]} {
   puts stderr "registry: $keys"
   exit 1
 }
 set version [lindex [lsort -real $keys] end]
 if {[catch {registry get HKEY_CLASSES_ROOT\\Typelib\\$typelib\\$version\\FLAGS {}} flag]} {
   puts stderr "registry: $flag"
   exit 1
 }
 if {[catch {registry get HKEY_CLASSES_ROOT\\Typelib\\$typelib\\$version\\$flag\\win32 {}} win32]} {
   puts stderr "registry: $win32"
   exit 1
 }
 if {[catch {::tcom::import $win32} olb]} {
   puts stderr "tcom: $olb"
   exit 1
 } 
 unset clsid typelib keys flag win32

Variables of the Type Library:

 foreach name [info vars ::${olb}::*] {
   puts $name
 }

Will output:

 ::Outlook::OlFormRegistry
 ::Outlook::OlMailingAddress
 ::Outlook::OlPermission
 ::Outlook::OlPermissionService
 ::Outlook::OlAttachmentType
 ::Outlook::OlViewType
 ::Outlook::OlGender
 ::Outlook::OlUserPropertyType
 ::Outlook::OlOfficeDocItemsType
 ::Outlook::OlStoreType
 ::Outlook::OlTaskStatus
 ::Outlook::OlRecurrenceType
 ::Outlook::OlShowItemCount
 ::Outlook::OlNetMeetingType
 ::Outlook::OlFlagIcon
 ::Outlook::OlInspectorClose
 ::Outlook::OlFlagStatus
 ::Outlook::OlActionCopyLike
 ::Outlook::OlFolderDisplayMode
 ::Outlook::OlTrackingStatus
 ::Outlook::OlBodyFormat
 ::Outlook::OlJournalRecipientType
 ::Outlook::OlMailRecipientType
 ::Outlook::OlEditorType
 ::Outlook::OlDaysOfWeek
 ::Outlook::OlResponseStatus
 ::Outlook::OlSensitivity
 ::Outlook::OlPane
 ::Outlook::OlMeetingStatus
 ::Outlook::OlSaveAsType
 ::Outlook::OlActionResponseStyle
 ::Outlook::__uuidof
 ::Outlook::OlTaskDelegationState
 ::Outlook::OlTaskRecipientType
 ::Outlook::OlTaskOwnership
 ::Outlook::OlMeetingResponse
 ::Outlook::OlWindowState
 ::Outlook::OlActionReplyStyle
 ::Outlook::OlActionShowOn
 ::Outlook::OlSyncState
 ::Outlook::OlBusyStatus
 ::Outlook::OlExchangeConnectionMode
 ::Outlook::OlImportance
 ::Outlook::OlSortOrder
 ::Outlook::OlNoteColor
 ::Outlook::OlRecurrenceState
 ::Outlook::OlDisplayType
 ::Outlook::OlRemoteStatus
 ::Outlook::OlItemType
 ::Outlook::OlDownloadState
 ::Outlook::OlTaskResponse
 ::Outlook::OlViewSaveOption
 ::Outlook::OlDefaultFolders
 ::Outlook::OlObjectClass
 ::Outlook::OlMeetingRecipientType
 ::Outlook::OlOutlookBarViewType

Contents of array ::Outlook::OlFormRegistry:

  parray ::Outlook::OlFormRegistry

Will output:

  ::Outlook::OlFormRegistry(olDefaultRegistry)      = 0
  ::Outlook::OlFormRegistry(olFolderRegistry)       = 3
  ::Outlook::OlFormRegistry(olOrganizationRegistry) = 4
  ::Outlook::OlFormRegistry(olPersonalRegistry)     = 2