[已解决]wmi显示盘符的问题
本帖最后由 synaspe 于 2015-11-16 13:47 编辑#include <Array.au3>
Local $t = "0"
Local $i="0"
Dim $avArray
Local $Output=""
Local $strComputer = "localhost"
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
If IsObj($colItems) then
For$objItem in $colItems
;MsgBox(0,"ID",$avArray)
_ArrayAdd( $avArray,$objItem.DeviceID)
$i=UBound($avArray)-1
Next
For $t = 0 to $i
MsgBox(0,"ID",$avArray[$t])
; GUICtrlSetState("$id","$avArray[$t]" & @CRLF)
Next
Else
Return
EndIf
就是能用 ; GUICtrlSetState("$id","$avArray[$t]" & @CRLF)这样显示在自己创建的gui界面上吗?如果不行应该使用什么方法显示?麻烦看下,谢谢! Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
If Not IsObj($colItems) Then Exit
Local $sAll = ''
For $objItem In $colItems
$sAll &= $objItem.DeviceID & '|'
Next
Local $hGui = GUICreate('本机盘符')
Local $iLst = GUICtrlCreateList('', 5, 5, 50, 120)
GUICtrlSetData(-1, $sAll)
GUISetState()
While GUIGetMsg() <> -3
WEnd 回复 2# afan
a大这个能用数组显示吗?因为我后续还想在数组里面每个盘符显示容量,$sAll应该是cdef一串显示的吧我再显示个别盘符的容量不好操作吧,新手上路请多指教{:face (356):} 回复 3# synaspe
把字符串切割一下就成数组了Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk")
If Not IsObj($colItems) Then Exit
Local $sAll = ''
For $objItem In $colItems
$sAll &= $objItem.DeviceID & '|'
Next
$sAll = StringTrimRight($sAll, 1)
Local $aDeviceID = StringSplit($sAll, '|', 2)
#Include <Array.au3>
_ArrayDisplay($aDeviceID) 回复 4# afan
谢谢a大了我再自己研究下 这么巧妙,点赞一下
页:
[1]