Results 1 to 4 of 4

Thread: Problem with using SearchTreeForFile to find files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    69

    Problem with using SearchTreeForFile to find files

    Hi,
    I am trying to find a file on a machine using
    SearchTreeForFile(RootPath, FileName, sBuffer)

    It seems to work fine on Win 98 and 2000, but on NT machines with Sp5 it returns 0 indicating that the file does not exist, but it does.
    What is wrong and how can I correct it?

  2. #2
    jim mcnamara
    Guest
    You declared the api like this? The ByVal part is important.

    Code:
    Private Declare Function SearchTreeForFile Lib "imagehlp.dll" _
    (ByVal sRootPath As String, _
     ByVal InputPathName As String, _
     ByVal OutputPathBuffer As String) As Boolean
    You call it like this

    Code:
    Public Function ff(sDrive As String, sFile As String) As String
    
    
        Dim str As String
        str = Space(MAX_PATH)
    
        If SearchTreeForFile(sDrive2Scan, sFile2Find, sResult) Then
    
                  ff = Left(sResult, InStr(str, vbNullChar) - 1)
        Else 
                  ff = "File not found: " & Err.LastDllError
            
        End If
    
    End Function

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    69

    SearchTreeForFile return empty string

    When I do it like this the SearchTreeForFile returns false, but the file does exist on the sDrive2Scan.

    Dim str As String
    str = Space(MAX_PATH)

    If SearchTreeForFile(sDrive2Scan, sFile2Find, sResult) Then

    ff = Left(sResult, InStr(str, vbNullChar) - 1)
    Else
    ff = "File not found: " & Err.LastDllError

    End If



    This works on Win 2000 and 9X, but not on Win NT SP5.
    What could be the error?

  4. #4
    jim mcnamara
    Guest
    Folder protections prevent scans.

    When you have Execute access you can get a file if you know the name beforehand. Otherwise you have to have Read access to the folder to scan it.

    Go in as admin and see if your code works on NT. It has to be protections, since Win2K is really NT 5.0

Posting Permissions

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



Click Here to Expand Forum to Full Width