如果是win7系统,可以用下面的方法,在win7 32位旗舰版测试成功
#include <Array.au3>
$Drive = DriveGetDrive("REMOVABLE")
If IsArray($Drive) Then
For $i = 1 To $Drive[0]
$hWnd = WinGetHandle("[CLASS:WdcWindow]")
If $hWnd = 0 Then
Run(@WindowsDir & "\System32\resmon.exe", "", @SW_HIDE)
$hWnd = WinWait("[CLASS:WdcWindow]")
EndIf
;Sleep(100)
ControlSetText("[CLASS:WdcWindow]", "", "[CLASS:Edit; INSTANCE:1]", "");清除原来内容
ControlSetText("[CLASS:WdcWindow]", "", "[CLASS:Edit; INSTANCE:1]", $Drive[$i]);发送新的内容
Sleep(4000)
$GetItemCount = ControlListView('[CLASS:WdcWindow]', '', 'SysListView327', 'GetItemCount')
If $GetItemCount >= 1 Then
Dim $array[$GetItemCount][3]
Else
MsgBox(4096, "提示", $Drive[$i] & "盘没发现占用进程")
ContinueLoop
EndIf
For $j = 1 To $GetItemCount
$array[$j - 1][0] = ControlListView('[CLASS:WdcWindow]', '', 'SysListView327', 'GetText', $j - 1, 0)
$array[$j - 1][1] = ControlListView('[CLASS:WdcWindow]', '', 'SysListView327', 'GetText', $j - 1, 1)
$array[$j - 1][2] = ControlListView('[CLASS:WdcWindow]', '', 'SysListView327', 'GetText', $j - 1, 3)
Next
_ArrayDisplay($array, "占用" & $Drive[$i] & "盘的进程列表", "", "", "", "", "序号|进程名称|进程PID|占用的文件路径")
Next
Else
Exit MsgBox(4096, "提示", "没发现可移动磁盘")
EndIf
WinClose($hWnd)
|