使用NtQueryDirectoryFile遍历文件/目录

本文提供了一段VB代码,利用NtQueryDirectoryFile API遍历指定目录下的文件和子目录,详细解释了代码中的数据结构和API调用,适合初学者学习NT系列函数和VB指针操作。
摘要由CSDN通过智能技术生成

好久没写文章了,今天发个以前写的一个代码,本来是VC的今天专门转换成了VB,希望能给一些有用的人一些帮助。

是高手就没必要看了,初学者可以学习下VB的指针操作,和NT系列函数的使用方法。

代码下载地址是:https://p-blog.csdn.net/images/p_blog_csdn_net/chenhui530/EntryImages/20080722/FindFile.jpg

Option Explicit

Private Type LARGE_INTEGER
    lowpart As Long
    highpart As Long
End Type

Private Type UNICODE_STRING
    uLength As Integer
    uMaximumLength As Integer
    pBuffer As Long
End Type

Private Type IO_STATUS_BLOCK
    Status As Long
    uInformation As Long
End Type

Private Type OBJECT_ATTRIBUTES
    Length As Long
    RootDirectory As Long
    ObjectName As Long
    Attributes As Long
    SecurityDescriptor As Long
    SecurityQualityOfService As Long
End Type

Private Type FILE_BOTH_DIRECTORY_INFORMATION
    NextEntryOffset As Long
    FileIndex As Long
    CreationTime As LARGE_INTEGER
    LastAccessTime As LARGE_INTEGER
    LastWriteTime As LARGE_INTEGER
    ChangeTime As LARGE_INTEGER
    EndOfFile As LARGE_INTEGER
    AllocationSize As LARGE_INTEGER
    FileAttributes As Long
    FileNameLength As Long
    EaSize As Long
    ShortNameLength As Byte
    ShortName(23) As Byte
    FileName As Byte '这里为了对齐,其实不用这个VB也是按4个字节对齐
    FileName1 As Integer '(519) As Byte
End Type

Private Const FileBothDirectoryInformation = 3
Private Const SYNCHRONIZE = &H100000
Private Const FILE_ANY_ACCESS = 0
Private Const FILE_LIST_DIRECTORY = 1
Private Const FILE_DIRECTORY_FILE = 1
Private Const FILE_SYNCHRONOUS_IO_NONALERT = &H20
Private Const FILE_OPEN_FOR_BACKUP_INTENT = &a

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值