Anyone here did anything with Windows Search Service APIs or do you have a solution/suggestion on how to search for keywords in multiple documents and multiple formats.
Yes, it is possible, but not simple.
- Windows Search works only in indexed folders, included in one of the special Libraries (Documents, Music, Video etc.). LIBRARIES, but NOT folders! This means, you must include your folders in one of these libraries.
- Windows Search uses ADO.
- You must use this connection string:
- Query example:
‘SELECT System.ItemPathDisplay FROM SystemIndex WHERE SCOPE=’‘file:’ & CLIP(LEFT(PATH())) & ‘\DOCS’ & ‘’’ and CONTAINS(’’"’ & CLIP(LEFT(GLO:SEARCH_STRING)) & ‘*"’’)’
- See MSDN and Clarion Help for details.
Thoughts in reply…
I note that Search is an option from the standard windows Shell Execute Windows api function. I have a very basic full clarion code example of this working in test only… but not posted here https://github.com/richardbryceau unfortunately… prehaps i can get this example updated later this week…
SELECT System.ItemPathDisplay FROM SystemIndex
Searching on “mssql SystemIndex” or “systemindex powershell” in Google is returning some interesting results…
Yes, it is possible too.
But unindexed search in 1 Tb hard drive will take a looooooooooooot of time…
When you say " This means, you must include your folders in one of these libraries." I want to save files into a folder on the PC - when I do that how do I include them in a library?
I am using ADO for Single Sign On to Active Directory so that should not be too difficult.
Is something like grep out of the question?
Not sure that will work. I need to search hundreds if not thousands of files that can be word or pdf format.
Now it became clearer…
So, let’s clarify what do you want: to search files on mask (*NAME?.PDF) or to search any files containing preassigned text.
In first case ShellExecute with “find” verb will be much more faster.
In second case you should use Windows Search.
There are two ways to add folder to library: you can do this manually or programmatically.
To add folder manually:
- Launch Windows Explorer.
- Select folder.
- Right-click on it.
- Select item like “Add to library” (sorry, my Windows is Russian… ).
- Select library.
To add folder programmatically:
You should use IShellLibrary interface (https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-ishelllibrary).
Not sure how long would i take but for searchable PDF files you can use QuickPDF Library to extract text and then search it
I have been using Copernic Desktop for the past 10 years for that.
It scan all drives even on a network. and report for the words you are looking for in all kind of format.
Reports from emails, txt pdf pictures , anything
I would need to be able to search . (word and pfd) in a specific folder for an unlimited number of keywords supplied by the user, so I would guess windows search is the way to go.
Thanks for the explanation on how to add the folder to a library.
Do they have an API to do that from my NetTalk program?
I don’t know. You could check their web site.
Didier Le Duc
“L’homme sage ne joue pas à saute mouton avec une licorne.”
Lao Tse …
I’m working on the same problem now. But I need to search both in local and network folders. It is quite different…
So, will you post a report about your results here?
P.S. If my posts are helpful for you, you may use “Like” button…