lele9013 发表于 2008-12-18 17:02:14

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

用于ghost还原的工具

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

并不能更进一步判断 一块硬盘里面包含几个分区。。。

gto250 发表于 2008-12-18 21:07:02

DriveGetDrive ( "类型" )
你可以使用这个呢,为什么还要写dll呢







http://lwc.nhome.cn/code/showip.asp

sanhen 发表于 2008-12-18 21:10:02

我在源码区记得发过。一块硬盘有几个分区的。是用WMI实现的。

lele9013 发表于 2008-12-19 10:19:03

wmi 不能在PE环境下运行啦

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

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

WMI 部分
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   

生成ini文件后 在读取

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

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

ahkang 发表于 2010-1-4 19:42:21

建议楼主也调用 DsptW.exe 吧,这家伙在 WinPE 系统下也能顺利运行。

afan 发表于 2010-1-4 19:46:07

回复 5# ahkang


    围观挖坟者……
页: [1]
查看完整版本: 居士大大 你能否用Pb 写一个 判断硬盘分区号的dll啦?