Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    find files marked for fast searching (any)

    I've been Googling[Groups] looking for any hint as to how one might detect/locate files marked "for fast searching allow indexing service to index this file", without success.
    Plenty of tips on how to manually right-click and unset the flag.
    But no code snippets that indicate how one might detect the setting.
    This Microsoft FSO page describes the File object, but I find no mention of the Indexing setting.

    (signed)"Stumped" from Toronto.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: find files marked for fast searching (any)

    How about the Windows API? Apparently there is a bit named FILE_ATTRIBUTE_NOT_CONTENT_INDEXED which might answer your question.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find files marked for fast searching (any)

    Jefferson thanks for the response.
    Interesting link (by definition, anything that I find slightly confusing is interesting)
    I made a brief experiment with code, but could not seem to get attribute bits reading higher than 2048, even on files which were described officially as "ready for indexing".
    I'll experiment some more over this weekend.
    Thanks again for the link!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: find files marked for fast searching (any)

    Here's an example, I hope it is self-explanatory.

    Declare Function GetFileAttributes Lib "kernel32.dll" _
    Alias "GetFileAttributesA" _
    (ByVal lpFileName As String) As Long

    Declare Function SetFileAttributes Lib "kernel32" _
    Alias "SetFileAttributesA" _
    (ByVal lpFileName As String, ByVal dwFileAttributes As Integer) As Integer

    Const FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = &H2000

    Sub Test()
    Dim intAtt As Integer
    Dim strFile As String

    strFile = "C:Anyfile.txt"

    intAtt = GetFileAttributes(strFile)
    MsgBox "Original attributes: " & intAtt

    SetFileAttributes strFile, intAtt Or FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
    intAtt = GetFileAttributes(strFile)
    MsgBox "Attributes after turning off marked for fast searching: " & intAtt

    SetFileAttributes strFile, intAtt Xor FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
    intAtt = GetFileAttributes(strFile)
    MsgBox "Original attributes reset: " & intAtt
    End Sub

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find files marked for fast searching (any)

    >Here's an example, I hope it is self-explanatory.
    Hans, thanks for the code, and yes, it is well-explained.
    I still don't understand what happens on my system.
    I have a file "strFile = "b:Billt2005.txt"" which (right-click,advanced) shows up with "For fast searching" checked ON.

    The first MsgBox reports intAtt as 32, that is, only the Archive bit is set on. I had expected a higher value to appear when I read the attributes of a file with "For fast searching" checked ON.
    (Deletes large chunks of response, replaces with "Whaaaaaat!")
    Whaaaaaat!
    I think I see the error in my ways.

    When Explorer reports "For fast searching" checked ON, the bit NOT_CONTENT_INDEXED is set OFF. It's the old and dastardly double-negative trick.
    Seeing (Explorer) the checkbox turned ON, I expected to see a Bit turned ON.
    I should, instead, have been looking for a bit NOT turned on.

    "Don't use negation in programming", is a saying that comes to mind .....

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: find files marked for fast searching (any)

    I ended up with this:<pre>Function blnIndexed(strFile As String) As Boolean
    Dim intAtt As Integer
    intAtt = GetFileAttributes(strFile)
    intAtt = (intAtt And FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
    blnIndexed = Not (intAtt > 0)
    'Sub TESTblnIndexed()
    ' MsgBox blnIndexed("B:Billt2005.txt")
    'End Sub
    End Function </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •