Friday, April 02, 2004

Searching with XP (Part 1)

(Thanks to Steve Trefethen)

Then I covered how to use Windows XP search inside Delphi (or any) source.  Turns out in XP they made the search not look in files unless they are setup in the registry as text.  If you look in the HKEY_CLASSES_ROOT\.txt you can see an entry that is setup correctly to be searchable.  You will notice a Content Type and PerceivedType.  I think the latter one is the important one for searching.  Also, there is a PersistentHandler key which contains a CLSID for the "Plain Text persistent handler".  If you export the .txt registry entry and edit for it .pas then it should look like this:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.pas]
"PerceivedType"="text"

[HKEY_CLASSES_ROOT\.pas\PersistentHandler]
@="{5e941d80-bf96-11cd-b579-08002b30bfeb}"

Be sure you leave the default value in the .pas key off or you will overwrite DelphiUnit with txtfile and all your source code will be opened with Notepad.  The important lines are the PerceivedType and the PersistentHandler key.

If you want more information be sure to check out some of those links.  Also, there is a program that does this automatically.  It is written in Delphi and comes free with source code.

No comments: