找回密码
 加入
搜索
查看: 2240|回复: 5

居士大大 你能否用Pb 写一个 判断硬盘分区号的dll啦?

[复制链接]
发表于 2008-12-18 17:02:14 | 显示全部楼层 |阅读模式
用于ghost还原的工具

原先居士哥哥写的 只能判断有几块硬盘

并不能更进一步判断 一块硬盘里面包含几个分区。。。
发表于 2008-12-18 21:07:02 | 显示全部楼层
DriveGetDrive ( "类型" )
你可以使用这个呢,为什么还要写dll呢







发表于 2008-12-18 21:10:02 | 显示全部楼层
我在源码区记得发过。一块硬盘有几个分区的。是用WMI实现的。
 楼主| 发表于 2008-12-19 10:19:03 | 显示全部楼层
wmi 不能在PE环境下运行啦

所以还是需要dll的。。。 0 0

我用wmi 的确能读取到,但一些环境的确不能运行dll 所以 还请居士大大帮下忙

WMI 部分
[au3]Func GetPartionMsg()
        $1 = 0
        $2 = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum", "Count")
        $strComputer = "localhost"
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
        $colDiskDrives = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
        For $objDrive In $colDiskDrives ;这里对硬盘的查询是倒序的,所以生成的“Partition.ini”中的硬盘也是倒序罗列的,这就要求主界面初始化 ListView 时最好倒序读取“Partition.ini”中的字段名。
                $strDeviceID = StringReplace($objDrive.DeviceID, "\", "\\")
                $colPartitions = $objWMIService.ExecQuery _
                                ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
                                $strDeviceID & """} WHERE AssocClass = " & _
                                "Win32_DiskDriveToDiskPartition")
                For $objPartition In $colPartitions
                        $colLogicalDisks = $objWMIService.ExecQuery _
                                        ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                                        $objPartition.DeviceID & """} WHERE AssocClass = " & _
                                        "Win32_LogicalDiskToPartition")
                        For $objLogicalDisk In $colLogicalDisks
                                $1 = $1 + 1
                                ;IniWrite(@AppDataDir & "\Ghost\97sky.ini", "HardDisk" & $2 & "_" & $objDrive.Caption, $objLogicalDisk.DeviceID, $objDrive.Index + 1 & ':' & $1)
                                IniWrite(@AppDataDir & "\Ghost\97sky.ini", "DiskList", $objLogicalDisk.DeviceID, $objDrive.Index + 1 & ':' & $1)
                        Next
                Next
                $2 = $2 - 1
                $1 = 0
        Next
        ToolTip("")
EndFunc   [/au3]

生成ini文件后 在读取

[au3]For $i = 1 To $var[0]
                        $fq = IniReadSection(@AppDataDir & "\Ghost\97sky.ini", $var[$i])
                        _ArraySort($fq)
                        If @error Then MsgBox(0, '', @error)
                        For $2 = 1 To $fq[0][0]
                                ;_ArrayAdd($AllDrive[1],
                               
                                $ac = DriveGetType($fq[$2][0] & "\")
                               
                                $aas = DriveGetFileSystem($fq[$2][0] & "\")
                                $aad = Round(DriveSpaceTotal($fq[$2][0] & "\") / 1024, 2)
                                $aab = Round(DriveSpaceFree($fq[$2][0] & "\") / 1024, 2)
                                If $fq[$2][0] = @HomeDrive Then
                                        $fq[$2][0] = $fq[$2][0] & "(系统)"
                                        $itemX = GUICtrlCreateListViewItem($fq[$2][0] & "|" & $fq[$2][1] & "|" & $aas & "|" & $aad & "|" & $aab, $List1)
                                        GUICtrlSetImage(-1, @AppDataDir & "\08.ico", 19)
                                Else
                                        If $ac = "Removable" Then
                                                $fq[$2][0] = $fq[$2][0] & "(U盘)"
                                                $abcd = GUICtrlCreateListViewItem($fq[$2][0] & "|" & $fq[$2][1] & "|" & $aas & "|" & $aad & "|" & $aab, $List1)
                                                GUICtrlSetImage(-1, @AppDataDir & "\005.ico", 19)
                                        Else
                                               
                                                $abcd = GUICtrlCreateListViewItem($fq[$2][0] & "|" & $fq[$2][1] & "|" & $aas & "|" & $aad & "|" & $aab, $List1)
                                                GUICtrlSetImage(-1, @AppDataDir & "\32.ico", 19)
                                        EndIf
                                EndIf
                        Next
                Next[/au3]

[ 本帖最后由 lele9013 于 2008-12-19 10:47 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-1-4 19:42:21 | 显示全部楼层
建议楼主也调用 DsptW.exe 吧,这家伙在 WinPE 系统下也能顺利运行。
发表于 2010-1-4 19:46:07 | 显示全部楼层
回复 5# ahkang


    围观挖坟者……
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-22 15:35 , Processed in 0.083461 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表