怎样返回指定隐藏文件的句柄? 
比如;boot.ini是系统文件,是隐藏的, 
但是用FindFirstFile,却查找不到该文件,当把boot.ini设置成可见文件后,FindFirstFile就能返回文件句柄。 实在是没折了,求求大家,给个可以返回隐藏文件句柄的API函数给我,万谢!!

解决方案 »

  1.   

    请看这篇文章
    http://blog.csdn.net/chenhui530/archive/2007/10/03/1810299.aspx
      

  2.   

    Option Explicit
    Private FSO As New FileSystemObject
    Private Stack() As String
    Private Pos As Long
    Private Pos_File As Long
    Private MyFolders As Folders
    Private MyFolder As Folder
    Private MyFiles As Files
    Private MyFile As File
    Private FileList() As String
    Private FileCount As Long
    Private FolderList() As String
    Private FolderCount As Long
    Private PathName As String
    Private Sub PushToDire(Val As String)
        ReDim Preserve Stack(Pos)
        Stack(Pos) = Val
        Pos = Pos + 1
    End Sub
    Private Function PullFromDire() As String
        Pos = Pos - 1
        If Pos < 0 Then
           Pos = 0
           PullFromDire = ""
           Exit Function
        End If
        PullFromDire = Stack(Pos)
        ReDim Preserve Stack(Pos)
    End Function
    Private Sub PushToFile(Val As String)
        ReDim Preserve FileList(FileCount)
        FileList(FileCount) = Val
        FileCount = FileCount + 1
    End Sub
    Private Function PullFromFile() As String
        FileCount = FileCount - 1
        If FileCount < 0 Then
            FileCount = 0
            PullFromFile = ""
            Exit Function
        End If
        PullFromFile = FileList(FileCount)
        ReDim Preserve FileList(FileCount)
    End Function
    Private Sub Push(Path As String)
        If Path = "" Then Exit Sub
        If Right(Path, 1) <> "\" Then Path = Path & "\"
        If Path = "" Or (Not FSO.FolderExists(Path)) Then
           Exit Sub
        End If
        Set MyFolders = FSO.GetFolder(Path).SubFolders
        For Each MyFolder In MyFolders
            PushToDire Path & MyFolder.Name
        Next
        Set MyFiles = FSO.GetFolder(Path).Files
        For Each MyFile In MyFiles
            PushToFile Path & MyFile.Name
        Next
    End Sub
    Public Function GetFirstFile(Path As String) As String
        Pos = 0
        FileCount = 0
        PathName = Path
        Push PathName
        GetFirstFile = GetNextFile
    End Function
    Public Function GetNextFile() As String
        Dim StrFileName As String
        StrFileName = ""
        Do While True
            StrFileName = PullFromFile
            If StrFileName <> "" Then
                GetNextFile = StrFileName
                Exit Do
            Else
                Dim StrDire
                StrDire = PullFromDire
                If StrDire = "" Then
                   GetNextFile = ""
                   Exit Function
                End If
                Push (StrDire)
            End If
        Loop
    End Function
    Public Function GetFirstDire(Path As String) As String
        Pos = 0
        FolderCount = 0
        PathName = Path
        Push PathName
        GetFirstDire = GetNextDire
    End Function
    Public Function GetNextDire() As String
        Do While True
           Dim StrDire As String
           StrDire = PullFromDire
           If StrDire = "" Then
                GetNextDire = ""
                Exit Function
           Else
                Push (StrDire)
                GetNextDire = StrDire
                Exit Function
           End If
        Loop
    End Function
      

  3.   

    曾经一回,发生错误"拒绝的权限",加上on error Goto 或 Resume next,但文件绝不错少的