Hallo zusammen.
Ich hab folgendes Problem: Im Programm WinSetupfromUSB gibt es folgende Funktion:
Func _GetUSBDrivesInfo()
Local $USBDlettersInfo[1][9], $NrOfFoundUSB = 0, $dp, $HasBootPart
Local $strComputer = ".", $objDrive, $strDeviceID, $colPartitions, $objPartition, $colLogicalDisks, $objLogicalDisk
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
If Not IsObj($objWMIService) Then
Logging("WMI appears to be broken")
$msg = MsgBox(4+48, "Warning !", "WMI (Windows Management Instrumentation) seems to be not working. It's needed to obtain USB disk properties." _
& @CRLF & "Press YES to visit a web page, describing how to repair it, or NO to exit the program")
If $msg = 6 Then
Run(@ComSpec & " /c " & 'start http://windowsxp.mvps.org/repairwmi.htm', "", @SW_HIDE)
Logging("WMI repair web page opened, closing program")
Quit()
Else
Logging("WMI repair web page refused, closing program")
Quit()
EndIf
EndIf
Local $colDiskDrives = $objWMIService.ExecQuery("Select * from Win32_DiskDrive Where (InterfaceType like " & chr(34) & "%USB%" & chr(34) & ")")
For $objDrive In $colDiskDrives
$HasBootPart = 0
Logging( "Found USB Physical Disk: " & $objDrive.Caption & " -- " & $objDrive.DeviceID)
$strDeviceID = StringReplace($objDrive.DeviceID, "\", "\\")
Local $colPartitions = $objWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & $strDeviceID & """}" _
& "WHERE AssocClass = Win32_DiskDriveToDiskPartition")
;check if this disk has bootable partitions
For $objPartition In $colPartitions
If $objPartition.Bootable = -1 Then
$HasBootPart = 1
ExitLoop
EndIf
Next
If $HasBootPart = 1 Then
For $objPartition In $colPartitions
Logging( "Found USB Disk Partition: " & $objPartition.DeviceID)
$colLogicalDisks = $objWMIService.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & $objPartition.DeviceID & """}" _
& "WHERE AssocClass = Win32_LogicalDiskToPartition" )
For $objLogicalDisk In $colLogicalDisks
Logging( "Found USB Logical Disk: " & $objLogicalDisk.DeviceID & " File system: " & $objLogicalDisk.FileSystem _
& " Bootable: " & $objPartition.Bootable)
$NrOfFoundUSB += 1
$USBDlettersInfo[0][0] = $NrOfFoundUSB
ReDim $USBDlettersInfo[$NrOfFoundUSB + 1][9]
$USBDlettersInfo[$NrOfFoundUSB][0] = $objLogicalDisk.DeviceID
$USBDlettersInfo[$NrOfFoundUSB][1] = StringReplace($objDrive.Caption, "USB device", "")
$dp = StringSplit($objPartition.DeviceID, ",")
$USBDlettersInfo[$NrOfFoundUSB][2] = StringRegExpReplace($dp[1], "[^0-9]", "")
$USBDlettersInfo[$NrOfFoundUSB][3] = StringRegExpReplace($dp[2], "[^0-9]", "")
$USBDlettersInfo[$NrOfFoundUSB][4] = Round(DriveSpaceTotal($objLogicalDisk.DeviceID), 0)
$USBDlettersInfo[$NrOfFoundUSB][5] = Round(DriveSpaceFree($objLogicalDisk.DeviceID), 0)
$USBDlettersInfo[$NrOfFoundUSB][6] = DriveGetType($objLogicalDisk.DeviceID)
$USBDlettersInfo[$NrOfFoundUSB][7] = $objLogicalDisk.FileSystem
;$USBDlettersInfo[$NrOfFoundUSB][8] = $objPartition.BootPartition
$USBDlettersInfo[$NrOfFoundUSB][8] = $objPartition.Bootable
;array is in format--> DriveLetter | Name | Disk# | Part# | TotalSpace | FreeSpace | DriveType | FileSystem | Bootable(-1) or Not (0)
Next
Next
EndIf
Next
Return $USBDlettersInfo
EndFunc ;==>__GetUSBDrivesInfo()
Das Programm würde ich gern unter WinPE benutzen, allerdings steht da die WMI nicht zur Verfügung.
Welche API bräuchte ich um die Funktion umzuschreiben?