Foxtable(狐表)用户栏目专家坐堂 → 调用Windows API


  共有3354人关注过本帖树形打印复制链接

主题:调用Windows API

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/29 11:37:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/29 12:14:00 [显示全部帖子]

递归参考

 

 下载信息  [文件大小:292.0 KB  下载次数:5]
图片点击可在新窗口打开查看点击浏览该文件:文件递归.table


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/29 13:38:00 [显示全部帖子]

全局代码

 

<DllImport("kernel32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto, SetLastError:=True)> _
Public Function FindFirstFile(ByVal pFileName As String, ByRef pFindFileData As WIN32_FIND_DATA) As IntPtr
End Function
<DllImport("kernel32.dll", CharSet:=System.Runtime.InteropServices.CharSet.Auto, SetLastError:=True)> _
Public Function FindNextFile(ByVal hndFindFile As IntPtr, ByRef lpFindFileData As WIN32_FIND_DATA) As Boolean
End Function
<DllImport("kernel32.dll", SetLastError:=True)> _
Public Function FindClose(ByVal hndFindFile As IntPtr) As Boolean
End Function

<Serializable, StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto), BestFitMapping(False)> _
Public Structure WIN32_FIND_DATA
Public dwFileAttributes As IO.FileAttributes
Public ftCreationTime_dwLowDateTime As UInteger
Public ftCreationTime_dwHighDateTime As UInteger
Public ftLastAccessTime_dwLowDateTime As UInteger
Public ftLastAccessTime_dwHighDateTime As UInteger
Public ftLastWriteTime_dwLowDateTime As UInteger
Public ftLastWriteTime_dwHighDateTime As UInteger
Public nFileSizeHigh As UInteger
Public nFileSizeLow As UInteger
Public dwReserved0 As Integer
Public dwReserved1 As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public cFileName As String
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> _
Public cAlternateFileName As String
End Structure

Public Function EnumerateFiles(ByVal path As String, ByVal Optional searchPattern As String = "*.*", ByVal Optional searchOption As IO.SearchOption = IO.SearchOption.AllDirectories)
Dim hFind As IntPtr = -1
Dim FindFileData As WIN32_FIND_DATA = Nothing

hFind = FindFirstFile(IO.Path.Combine(path, searchPattern), FindFileData)
If hFind <> -1 Then
   
    Do
        If FindFileData.cFileName.Equals(".") OrElse FindFileData.cFileName.Equals("..") Then Continue Do
       
        If  searchOption = io.SearchOption.AllDirectories AndAlso ((FindFileData.dwFileAttributes And io.FileAttributes.Directory) = io.FileAttributes.Directory) Then
            'output.show(io.Path.Combine(path, FindFileData.cFileName))
            EnumerateFiles(io.Path.Combine(path, FindFileData.cFileName))
        Else
            output.show(io.Path.Combine(path, FindFileData.cFileName))
        End If

    Loop While FindNextFile(hFind, FindFileData)
    FindClose(hFind)
   
End If

End Function

 

 

调用代码

 

EnumerateFiles("d:\")


 回到顶部