fanishare 发表于 2008-8-18 14:45:14

谁帮我看下这段代码该如何理解

#include <GUIConstants.au3>
#notrayicon
dim $ListView1
GUICreate("简单的进程管理器", 257, 364)
$Button1 = GUICtrlCreateButton("结束进程", 8, 328, 105, 25)
$Button2 = GUICtrlCreateButton("刷新列表", 144, 328, 105, 25)
$ListView1 = list()

GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button1
proclose()
Case $msg = $Button2
$ListView1 = list()
EndSelect
WEnd
Exit

func list()
if $ListView1 then GUICtrlDelete($ListView1)
$list = ProcessList()
$ListView1 = GUICtrlCreateListView("进程名                              |PID      ", 8, 8, 241, 305)
for $i = 1 to $list;进程总数
       
GUICtrlCreateListViewItem($list[$i]&"|"&$list[$i],$listview1)
next
return $ListView1
endfunc

func proclose()
$pro = stringsplit(GUICtrlRead(GUICtrlRead($listview1)),"|")      //这里是什么意思,为什么需要两个GUICtrlRead命令,返回值的含义又是啥?
if $pro = 2 then
if ProcessExists($pro) then ProcessClose($pro);;runwait(@ComSpec & " /c taskkill /f /t /pid " & $pro,"",@sw_hide)
else
   msgbox(4096,"错误","无法终止进程!")
EndIf
sleep(1000)
if $pro = 2 then
if ProcessExists($pro) then
msgbox(4096,"错误","无法终止进程!")
return
endif
endif
$ListView1 = list()
endfunc

aa147147 发表于 2008-8-18 15:21:49

读取$listview1中当前焦点的数据

fanishare 发表于 2008-8-18 16:37:36

这个命令我了解,关键是为啥要两个,真奇怪哦,呵呵

sxd 发表于 2009-9-1 04:04:41

很明显这是个错误的代码.....我结束任何东西都结束不了.....那一句的原意是获取pid来终止进程
页: [1]
查看完整版本: 谁帮我看下这段代码该如何理解