SpotlightQuery.Constructor(query as String)

From Xojo Documentation

Revision as of 22:51, 29 August 2019 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


SpotlightQuery.Constructor([query as String])

Creates a SpotlightQuery object, optionally with the passed query. If not passed, it defaults to no query.


The following synchronous query populates a ListBox with the list of audio files on the user’s computer and the absolute path to each file. You can put the code in a PushButton.

Var query As New SpotlightQuery("kMDItemContentTypeTree == ''")
query.Synchronous = True
For i As Integer = 0 To query.Count - 1
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = query.Item(i).File.NativePath

Exception e As SpotlightException
MessageBox("A Spotlight error occurred.")