⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmfileanddiroperate.frm

📁 磁盘FAT扇区数据读写操作 Ver 1.20(更新版)
💻 FRM
📖 第 1 页 / 共 5 页
字号:
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "处理文件夹"
         BackStyle       =   0
         RadioType       =   2
      End
      Begin Project1.wwradio Option4 
         Height          =   315
         Left            =   75
         TabIndex        =   12
         Top             =   285
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   556
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "处理文件"
         BackStyle       =   0
         Value           =   -1  'True
         RadioType       =   2
      End
   End
   Begin VB.TextBox Text2 
      Height          =   330
      Left            =   2595
      TabIndex        =   2
      Top             =   180
      Width           =   4770
   End
   Begin Project1.wwbutton wwExit 
      Height          =   570
      Left            =   5670
      TabIndex        =   0
      Top             =   2445
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   1005
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "退出(&E)"
   End
   Begin Project1.XP_ProgressBar PBar 
      Height          =   345
      Left            =   2235
      TabIndex        =   1
      Top             =   1350
      Width           =   6285
      _ExtentX        =   11086
      _ExtentY        =   609
      Color           =   2628892
   End
   Begin Project1.wwbutton wwBrowse 
      Height          =   375
      Left            =   7395
      TabIndex        =   10
      Top             =   135
      Width           =   1080
      _ExtentX        =   1905
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "浏览...(&B)"
   End
   Begin VB.Label Label3 
      Height          =   555
      Left            =   2295
      TabIndex        =   8
      Top             =   1785
      Width           =   6135
   End
   Begin VB.Label Label2 
      Caption         =   "保存位置"
      Height          =   240
      Left            =   1785
      TabIndex        =   6
      Top             =   660
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "处理目标"
      Height          =   255
      Left            =   1785
      TabIndex        =   5
      Top             =   255
      Width           =   780
   End
End
Attribute VB_Name = "FrmFileAndDirOperate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/09/30  更新日期:2007/10/09
'描    述:磁盘FAT扇区数据读写操作 Ver 1.20
'网    站:http://www.Mndsoft.com/  (VB6源码博客)
'网    站:http://www.VbDnet.com/   (VB.NET源码博客,主要基于.NET2005)
'e-mail  :Mndsoft@163.com
'e-mail  :Mndsoft@126.com
'OICQ    :88382850
'          如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************

Option Explicit

Private Const MaxLFNPath = 260
Private Const OFFSET_4 = 4294967296#
Private Const OFFSET_2 = 65536
'Private Const MAXINT_4 = 2147483647
'Private Const MAXINT_2 = 32767

Private Type DirInfo                            '自定义一个包含目录项信息的Type
      sDir As String                            '目标名称
      sDisk As String                           '磁盘名称
      Cluster As Double                         '该文件夹或是文件自己的目录内容起始簇号,如同一个文件的内容的起始簇号
      dStartLoc As Double                       '父目录起始地址(这里是存放簇的起始地址)
      lUp As Long                               '名称占用几个目录项
      lPos As Long                              '偏移到第几个目录项
      bIsCrash As Boolean                       '是否粉碎处理
      bIsOverCluster As Boolean                 '是否跨簇位置
      dOverStartLoc As Double                   '跨簇或扇区的起始地址
      lOverUp As Long                           '文件夹名称跨簇或扇区的部分占用几个目录项,注:一个目录项占用32个字节
End Type
Private Type SafeArray1d                        '1维数组的 SafeArray 定义
        cDims As Integer                        '维数
        fFeatures As Integer                    '标志
        cbElements As Long                      '单个元素的字节数
        clocks As Long                          '锁定计数
        pvData As Long                          '指向数组元素的指针
        cElements As Long                       '维定义,该维的元素个数
        Lbound As Long                          '该维的下界
 End Type
Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long

Private pBytesInLong() As Byte               '用于把字节直接变成Long型而不经过任何计算
Private SA1D As SafeArray1d
Private lPublicLong As Long              '定义一个公共交换的长整型数
Private pBytesInInteger() As Byte
Private SA1DInt As SafeArray1d
Private lPublicInt As Integer
'以下定义几个要用的公共变量
Private lFatEntries As Long              'FAT表入口扇区偏移(本程序以FAT1开始)
Private lFatStartSector As Long          'FAT表入口起始扇区号
Private lRootEntries As Double           '根目录入口扇区偏移地址
Private lRootStartSector As Double       '根目录入口起始扇区

Private lSectorPerFat As Double          '每FAT占的扇区数,这个数要定义大一些,在FAT32中这个数就很大
Private lReservedSector As Long          '保留扇区数
Private lRootSector As Long              '根目录所占扇区数
Private lFatNum As Long                  'FAT表个数
Private lBytePerSector As Long           '每扇区字节数
Private lSectorPerCluster As Long        '每簇扇区数
Private lDataEntries As Double           '数据区入口地址偏移
Private lDataStartSector As Double       '数据区入口起始扇区
Private lFileSystemType As Long          '文件系统类型 1为FAT16 2为FAT32 3为NTFS
Private lFileEndFlag As Double           '文件结束标志
Private hhToken As Long                  '恢复权取用


Private iOperateFlag As Integer          '任务标记 如:1、2、3、4、5等
Private sLabelCaption As String
Private CodeCluster() As Long            '定义一个数组来存储所有的簇号
Private lTempClusterNum As Long          '簇号数量计数
Private DirSector() As DirInfo           '定义一个数组存储所有的目录项
Private lTempDirSectorNum As Long        '目录项数量计数

'----------------------------------------------
' Procedure  : ByteToLongInit
' Auther     : WangWeiSheng
' Input      : None
' OutPut     : None
' Purpose    : 把一个字节数组的起始地址同一个长整型数的地址等起来
'----------------------------------------------
Private Sub ByteToLongInit()
With SA1D
     .cDims = 1
     .fFeatures = 17
     .cbElements = 1
     .clocks = 0
     .pvData = VarPtr(lPublicLong)                         '使公共交换的长整形变量的指针与中间交换字节数组的指针等起来
     .cElements = 4
     .Lbound = 0
End With
CopyMemory ByVal VarPtrArray(pBytesInLong), VarPtr(SA1D), 4 '---使数组变量(其实就是个指针)指向我们自己创建的 SafeArray1d 结构

End Sub
'----------------------------------------------
' Procedure  : ByteToIntInit
' Auther     : WangWeiSheng
' Input      : None
' OutPut     : None
' Purpose    : 把一个字节数组的起始地址同一个整型数的地址等起来
'----------------------------------------------
Private Sub ByteToIntInit()
With SA1DInt
     .cDims = 1
'     .fFeatures = 17
     .cbElements = 1
     .clocks = 0
     .pvData = VarPtr(lPublicInt)                         '使公共交换的整形变量的指针与中间交换字节数组的指针等起来
     .cElements = 2
     .Lbound = 0
End With
CopyMemory ByVal VarPtrArray(pBytesInInteger), VarPtr(SA1DInt), 4 '---使数组变量(其实就是个指针)指向我们自己创建的 SafeArray1d 结构

End Sub

Private Sub wwBrowse_Click()
Dim vvOpenFile As OPENFILENAME
Dim sFileName As String
Dim ssFilter As String
Dim sDir As String

If Option4.Value Then
   ssFilter = "所有文件(*.*)" & Chr(0) & "*.*" & Chr(0)
   Text2 = GetDlgRtnFileName(1, vvOpenFile, Me.hwnd, ssFilter, "选择文件", "*.*" & Chr(0), sFileName)
   If StrComp(Text2.Text, "Cancel", vbTextCompare) = 0 Then
      Text2 = ""
      Exit Sub        '如果点的是“取消”按钮,则结束
   End If
Else
   sDir = SynBrowseForFolder(Me.hwnd, "请选择你的文件夹地址")
   If Len(sDir) = 0 Then Exit Sub
   Text2 = sDir
End If
End Sub
Private Sub wwBrowse1_Click()
Dim sDir As String
   sDir = SynBrowseForFolder(Me.hwnd, "请选择你的文件夹地址")
   If Len(sDir) = 0 Then Exit Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -