因为要在Winpe下作自动Ghost,所以需要在Winpe下将分区的盘符转换为分区号,如何用API函数中的GetSystemDirectory实现,其他函数若能实现也可以。
请高人帮忙!!!!

解决方案 »

  1.   

    在Vb中新建工程,创建一个DriveListBox控件,并加入如下代码,运行程序,点击DriveListBox,程序会根据DriveListBox里的盘符在桌面上打印出分区号,如1.2的形式,意思是第一个硬盘的第二个分区,你可以更具自己的需要更改下面的代码。
    Public DL_R As String
    Public DL_PN As String
    Public DL_PD As String
    Private Sub Get_PN(DL As String)
      WQL = "Associators of {win32_LogicalDisk='" & DL & "'} where resultClass = Win32_DiskPartition"
      Set Pattions = GetObject("winmgmts:").ExecQuery(WQL)
      For Each Pat In Pattions
          DL_PN = Pat.Name
          DL_PD = Pat.DiskIndex
          DL_R = CInt(DL_PD + 1) & ":" & CInt(Right(DL_PN, 1) + 1)
      Next
    End SubPrivate Sub Drive1_Change()
      Get_PN (Left(Drive1.Drive, 2))
      Print DL_R
    End SubPrivate Sub Form_Load()
      Get_PN (Left(Drive1.Drive, 2))
      'Print DL_PD
      Print DL_R
    End Sub
      

  2.   

    忘了说,在Winpe中运行WMI要给Winpe安装WMI工具包,具体怎样安装可以参考Winpe的帮助手册。