📄 form1.frm
字号:
For keer = 1 To 26
If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
drvName = Left$(strSave, InStr(1, strSave, Chr$(0)) - 2)
Combo1.AddItem drvName
strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
Next 'keer
Combo1.ListIndex = 1
End Sub
Sub ReadDisk(Disk As String, Sector As Double)
Dim a As String
Dim B As String
Dim tem As String
Dim sPos As String
Dim sVolume As String
Dim sUCDVolume() As Byte
Dim i As Long
Dim lSmallSector As Long
Dim lSectorPerFat As Double
Dim lReservedSector As Long
Dim dDiskBytes As Double
Dim dStartPos As Double
Dim lPosLow As Long
Dim lPosHigh As Long
'Dim lAllSector As Double
Dim lSectorPerFat32 As Double
Const S0 = "0000000000"
ReDim sUCDVolume(21)
Picture1.Cls
Picture1.ForeColor = vbBlue
TextOut Picture1.hdc, 30, 5, "Offset", Len("Offset")
For Log_Col = 0 To 15
a = Hex$(Log_Col) '改成直接用16進制表示更好
TextOut Picture1.hdc, 20 * Log_Col + 90, 5, a, 1& 'Len(a)
Next
Picture1.ForeColor = vbRed
Picture1.Line (0, 18)-(700, 18)
Picture1.Line (410, 0)-(410, 900)
Picture1.Line (80, 0)-(80, 900) '增加一根竖线
ReDim Byte_data(511)
' On Error GoTo 10
'----------------------------------------------
OpenDisk "\\.\" & Disk
' ReadDiskbyPos Byte_data(), 512 * Sector, 512
ReadDiskbySector Byte_data(), Sector, 1
CloseDisk
'----------------------------------------------
For Log_Row = 0 To 31
'以下三行是增加偏移量表示
'dStartPos
lPosHigh = Int((Log_Row * 16 + Sector * 512) / OFFSET_4)
lPosLow = UnsignedToLong(Log_Row * 16 + Sector * 512 - lPosHigh * OFFSET_4)
' a = Hex$(Log_Row * 16 + Sector * 512)
a = Hex$(lPosLow)
B = Hex$(lPosHigh)
a = B & a
sPos = Left$(S0, 10 - Len(a)) & a
Picture1.ForeColor = vbBlue
TextOut Picture1.hdc, 10, 15 * Log_Row + 20, sPos, Len(sPos)
Picture1.ForeColor = &H0&
For Log_Col = 0 To 15
If Byte_data(Log_Row * 16 + Log_Col) < 16 Then
tem = "0" & Hex(Byte_data(Log_Row * 16 + Log_Col))
Else
tem = Hex(Byte_data(Log_Row * 16 + Log_Col))
End If
TextOut Picture1.hdc, 20 * Log_Col + 90, 15 * Log_Row + 20, tem, &O2
If Byte_data(Log_Row * 16 + Log_Col) < &H20 Then
tem2(Log_Col) = &H2E
Else
tem2(Log_Col) = Byte_data(Log_Row * 16 + Log_Col)
End If
Next
tem1(0) = StrConv(tem2(), vbUnicode)
TextOut Picture1.hdc, 20 * 16 + 100, 15 * Log_Row + 20, tem1(0), 16
Next
Me.Caption = "当前磁盘:" & Combo1.Text
If Sector <> 0 Then Exit Sub
Command2.Enabled = True
If Byte_data(1) = &H3C Then
'得到OEMID
For i = 0 To 7
sUCDVolume(2 * i) = Byte_data(i + 3)
Next
sVolume = sUCDVolume '在VB中,把数组变成Unicode格式,可以直接把数组与字符串等起来
sVolume = Trim(Left(sVolume, InStr(1, sVolume, Chr$(0), vbTextCompare)))
Label19.Caption = sVolume
For i = 0 To 7
sUCDVolume(2 * i) = 0 '恢复为0
Next
'得到每扇区字节数
pBytesInInteger(0) = Byte_data(&HB)
pBytesInInteger(1) = Byte_data(&HC)
Label3.Caption = Str$(lPublicInt)
'得到每簇扇区数
Label5.Caption = Str$(Byte_data(&HD))
'FAT 表个数
Label12.Caption = Str$(Byte_data(&H10))
'得到根目录项数
pBytesInInteger(0) = Byte_data(&H11)
pBytesInInteger(1) = Byte_data(&H12)
Label21.Caption = Str$(lPublicInt)
'得到小扇区数
pBytesInInteger(0) = Byte_data(&H13)
pBytesInInteger(1) = Byte_data(&H14)
lSmallSector = IntToUnsigned(lPublicInt)
Label25.Caption = Str$(lSmallSector)
'得到媒体描述符
Label23.Caption = Str$(Byte_data(&H15))
'FAT 表占用扇区数
pBytesInInteger(0) = Byte_data(&H16)
pBytesInInteger(1) = Byte_data(&H17)
' lSectorPerFat = lPublicInt
Label9.Caption = Str$(IntToUnsigned(lPublicInt))
'得到大扇区数
pBytesInLong(0) = Byte_data(&H20)
pBytesInLong(1) = Byte_data(&H21)
pBytesInLong(2) = Byte_data(&H22)
pBytesInLong(3) = Byte_data(&H23)
lAllSector = LongToUnsigned(lPublicLong)
Label27.Caption = Str$(lAllSector)
'得到总扇区数
If lSmallSector = 0 Then
Label7.Caption = Str$(lAllSector)
Else
lAllSector = lSmallSector
Label7.Caption = Str$(lAllSector)
End If
VS1.Max = lAllSector
'得到隐藏扇区数
pBytesInLong(0) = Byte_data(&H1C)
pBytesInLong(1) = Byte_data(&H1D)
pBytesInLong(2) = Byte_data(&H1E)
pBytesInLong(3) = Byte_data(&H1F)
Label15.Caption = Str$(LongToUnsigned(lPublicLong))
'保留扇区数
pBytesInInteger(0) = Byte_data(&HE)
pBytesInInteger(1) = Byte_data(&HF)
' lReservedSector = IntToUnsigned(lPublicInt)
' Label35.Caption = Str$(lReservedSector)
Label35.Caption = Str$(IntToUnsigned(lPublicInt))
'得到卷序号
pBytesInLong(0) = Byte_data(&H43)
pBytesInLong(1) = Byte_data(&H44)
pBytesInLong(2) = Byte_data(&H45)
pBytesInLong(3) = Byte_data(&H46)
Label29.Caption = Str$(LongToUnsigned(lPublicLong))
'得到卷标
For i = 0 To 10
sUCDVolume(2 * i) = Byte_data(&H2B + i) '2b
Next
sVolume = sUCDVolume '在VB中,把数组变成Unicode格式,可以直接把数组与字符串等起来
Label31.Caption = sVolume
For i = 0 To 10
sUCDVolume(2 * i) = 0 '恢复为0
Next
'文件系统类型
For i = 0 To 7
sUCDVolume(2 * i) = Byte_data(&H36 + i) '36
Next
sVolume = sUCDVolume
sVolume = Trim(Left(sVolume, InStr(1, sVolume, Chr$(0), vbTextCompare)))
Label33.Caption = sVolume
'磁盘字节数
'磁盘字节数 = (总扇区数 - FAT 表占用扇区数 * FAT 表个数 - 保留扇区数) * 得到每扇区字节数
dDiskBytes = lAllSector - lSectorPerFat * Byte_data(&H10) - lReservedSector
Label11.Caption = dDiskBytes * 512 & "字节" & vbCrLf & "约" & CLng(dDiskBytes * 512 / 1024 / 1024) & "M"
ElseIf Byte_data(1) = &H58 Then
'得到OEMID
For i = 0 To 7
sUCDVolume(2 * i) = Byte_data(i + 3)
Next
sVolume = sUCDVolume '在VB中,把数组变成Unicode格式,可以直接把数组与字符串等起来
sVolume = Trim(Left(sVolume, InStr(1, sVolume, Chr$(0), vbTextCompare)))
Label19.Caption = sVolume
For i = 0 To 7
sUCDVolume(2 * i) = 0 '恢复为0
Next
'得到每扇区字节数
pBytesInInteger(0) = Byte_data(&HB)
pBytesInInteger(1) = Byte_data(&HC)
Label3.Caption = Str$(lPublicInt)
'得到每簇扇区数
Label5.Caption = Str$(Byte_data(&HD))
'FAT 表个数
Label12.Caption = Str$(Byte_data(&H10))
'得到根目录项数
pBytesInInteger(0) = Byte_data(&H11)
pBytesInInteger(1) = Byte_data(&H12)
Label21.Caption = Str$(lPublicInt)
'得到小扇区数
pBytesInInteger(0) = Byte_data(&H13)
pBytesInInteger(1) = Byte_data(&H14)
lSmallSector = IntToUnsigned(lPublicInt)
Label25.Caption = Str$(lSmallSector)
'得到媒体描述符
Label23.Caption = Str$(Byte_data(&H15))
'FAT 表占用扇区数
pBytesInLong(0) = Byte_data(&H24)
pBytesInLong(1) = Byte_data(&H25)
pBytesInLong(2) = Byte_data(&H26)
pBytesInLong(3) = Byte_data(&H27)
lSectorPerFat32 = LongToUnsigned(lPublicLong)
Label9.Caption = Str$(lSectorPerFat32)
'得到大扇区数
pBytesInLong(0) = Byte_data(&H20)
pBytesInLong(1) = Byte_data(&H21)
pBytesInLong(2) = Byte_data(&H22)
pBytesInLong(3) = Byte_data(&H23)
lAllSector = LongToUnsigned(lPublicLong)
Label27.Caption = Str$(lAllSector)
'得到总扇区数
Label7.Caption = Str$(lAllSector)
VS1.Max = lAllSector
'得到隐藏扇区数
pBytesInLong(0) = Byte_data(&H1C)
pBytesInLong(1) = Byte_data(&H1D)
pBytesInLong(2) = Byte_data(&H1E)
pBytesInLong(3) = Byte_data(&H1F)
Label15.Caption = Str$(LongToUnsigned(lPublicLong))
'保留扇区数
pBytesInInteger(0) = Byte_data(&HE)
pBytesInInteger(1) = Byte_data(&HF)
lReservedSector = IntToUnsigned(lPublicInt)
Label35.Caption = Str$(lReservedSector)
'得到卷序号
pBytesInLong(0) = Byte_data(&H27)
pBytesInLong(1) = Byte_data(&H28)
pBytesInLong(2) = Byte_data(&H29)
pBytesInLong(3) = Byte_data(&H2A)
Label29.Caption = Str$(LongToUnsigned(lPublicLong))
'得到卷标
For i = 0 To 10
sUCDVolume(2 * i) = Byte_data(&H47 + i)
Next
sVolume = sUCDVolume '在VB中,把数组变成Unicode格式,可以直接把数组与字符串等起来
Label31.Caption = sVolume
For i = 0 To 10
sUCDVolume(2 * i) = 0 '恢复为0
Next
'文件系统类型
For i = 0 To 7
sUCDVolume(2 * i) = Byte_data(&H52 + i)
Next
sVolume = sUCDVolume
sVolume = Trim(Left(sVolume, InStr(1, sVolume, Chr$(0), vbTextCompare)))
Label33.Caption = sVolume
'磁盘字节数
'磁盘字节数 = (总扇区数 - FAT 表占用扇区数 * FAT 表个数 - 保留扇区数) * 得到每扇区字节数
dDiskBytes = lAllSector - lSectorPerFat32 * Byte_data(&H10) - lReservedSector
Label11.Caption = dDiskBytes * 512 & "字节" & vbCrLf & "约" & CLng(dDiskBytes * 512 / 1024 / 1024) & "M"
Else
Exit Sub
End If
Exit Sub
10
If Err.Number = 52 Then Me.Caption = "错误号:" & Err.Number & vbCrLf & Err.Description
Label3.Caption = "": Label5.Caption = "": Label7.Caption = "": Label9.Caption = ""
Label12.Caption = "": Label15.Caption = "": Label11.Caption = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
CopyMemory ByVal VarPtrArray(pBytesInLong), 0&, 4
CopyMemory ByVal VarPtrArray(pBytesInInteger), 0&, 4
End Sub
Private Function LongToUnsigned(Value As Long) As Double
If Value < 0 Then
LongToUnsigned = Value + OFFSET_4
Else
LongToUnsigned = Value
End If
End Function
Private Function IntToUnsigned(Value As Integer) As Long
If Value < 0 Then
IntToUnsigned = Value + OFFSET_2
Else
IntToUnsigned = Value
End If
End Function
'
Private Sub VS1_Change(Value As Currency)
Call ReadDisk(Combo1.Text, VS1.Value)
Label17.Caption = VS1.Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -