📄 modexp.bas
字号:
Attribute VB_Name = "modExp"
Option Explicit
Public Function scanHDs(tvhd As TreeView)
Busy
Dim a As Object, b As Object, c As Object
Set a = GetObject("winmgmts:{ImpersonationLevel=Impersonate}\root\cimv2").InstancesOf("Win32_DiskDrive")
tvhd.Nodes.Clear
For Each b In a
DoEvents
tvhd.Nodes.Add , , "hd" & b.Index, "Disk#" & b.Index
tvhd.Nodes("hd" & b.Index).Tag = b.Partitions & "|" & _
b.TotalCylinders & "|" & _
b.TracksPerCylinder & "|" & _
b.SectorsPerTrack & "|" & _
b.BytesPerSector & "|" & _
b.TotalSectors & "|" & _
b.TotalHeads '
Debug.Print b.name
If OpenDrive(b.name) Then
getHandlerPartitions tvhd, "hd" & b.Index
closeDrive
End If
Next
Set a = Nothing
Set b = Nothing
Busy 0
End Function
Public Sub getHandlerPartitions(tvn As TreeView, key As String)
Dim ret&, bret&
ret& = DeviceIoControl(drvHandle, IOCTL_DISK_GET_DRIVE_LAYOUT, ByVal 0&, 0&, ByVal VarPtr(dli), Len(dli), bret, ByVal 0)
For ret = 0 To dli.PartitionCount - 1
DoEvents
With dli.PartitionEntry(ret)
If .PartitionLength.lowpart <> 0 And .PartitionNumber <> 0 Then
tvn.Nodes.Add key, tvwChild, "pr" & .PartitionNumber, "#" & .PartitionNumber & IIf(.PartitionType = 7, "ntfs ", "? ") & Format(CDbl((.PartitionLength.highpart * (2 ^ 32) + .PartitionLength.lowpart) / MB), "0 \M\B") & ", o " & ((.StartingOffset.highpart * (2 ^ 32) + .StartingOffset.lowpart) / 512)
tvn.Nodes("pr" & .PartitionNumber).Tag = ((.StartingOffset.highpart * (2 ^ 32) + .StartingOffset.lowpart) / 512)
End If
End With
Next
tvn.Nodes(key).Expanded = True
tvn.Nodes(key).EnsureVisible
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -