Interfacing Windows Search

Interfacing with the Windows Search database can be useful for various purposes, if only because it's nice to access this from Tcl. The Windows Search database is accessible using COM. Below a small example for executing a query.

 package require tcom
 set ProgID ADODB.Connection
 set application [::tcom::ref createobject $ProgID] 
 $application Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
 set sql "SELECT Top 5 System.ItemPathDisplay FROM SYSTEMINDEX"
 set rst [$application Execute $sql]
 puts [split [$rst GetString] \r]

bjorktcl - 2024-07-31 20:22:23

Same as above, except using twapi.

 package require twapi
 set ProgID ADODB.Connection
 set application [::twapi::comobj $ProgID] 
 $application Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"
 set sql "SELECT Top 5 System.ItemPathDisplay FROM SYSTEMINDEX"
 set rst [$application Execute $sql]
 puts [split [$rst GetString] \r]