当前位置:编程学习 > VB >>

如何用API将盘符转换成分区号

因为要在Winpe下作自动Ghost,所以需要在Winpe下将分区的盘符转换为分区号,如何用API函数中的GetSystemDirectory实现,其他函数若能实现也可以。
请高人帮忙!!!!
--------------------编程问答-------------------- 很关注! --------------------编程问答-------------------- 在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 Sub

Private Sub Drive1_Change()
  Get_PN (Left(Drive1.Drive, 2))
  Print DL_R
End Sub

Private Sub Form_Load()
  Get_PN (Left(Drive1.Drive, 2))
  'Print DL_PD
  Print DL_R
End Sub
--------------------编程问答-------------------- 忘了说,在Winpe中运行WMI要给Winpe安装WMI工具包,具体怎样安装可以参考Winpe的帮助手册。
补充:VB ,  API
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,