如何获取几个进程的路径并写入到文件啊[已解决]
本帖最后由 today2004 于 2010-8-13 21:37 编辑我写的怎么每次写入到文件就最后一个进程的路径写入了 其他的都没有写入
FileChangeDir (@ScriptDir)
Dim $var
$var=IniReadSection("setcfg.ini","进程")
If @error Then
MsgBox(16,"错误","请检查“setcfg.ini”是否存在或配置是否正确!")
Exit
Else
For $i = 1 To $var
If $var[$i] = "1" Then
ProcessExists($var[$i])
$iPid=ProcessExists($var[$i])
EndIf
Next
$file = FileOpen("test.txt", 1)
If $file = -1 Then
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
FileWrite($file, _GetModuleFileNameEx($iPid)& @CRLF)
EndIf
Func _GetModuleFileNameEx($_Pid)
$_Hwnd=DllCall("Kernel32.dll","hwnd","OpenProcess","dword",0x0400+0x0010,"int",0,"dword",$_Pid)
$_Return=DllCall("Psapi.dll","long","GetModuleFileNameEx","hwnd",$_Hwnd,"long",0,"str",0,"long",255)
DllCall("Kernel32.dll","int","CloseHandle","hwnd",$_Hwnd)
If StringInStr($_Return,"\") Then Return $_Return
Return ""
EndFunc
高手指导哈谢谢 FileChangeDir(@ScriptDir)
Dim $var = IniReadSection("setcfg.ini", "进程")
If @error Then Exit MsgBox(16, "错误", "请检查“setcfg.ini”是否存在或配置是否正确!")
Dim $out
For $i = 1 To $var
If $var[$i] = "1" Then
$iPid = ProcessExists($var[$i])
If Not $iPid Then ContinueLoop
$out &= _GetModuleFileNameEx($iPid) & @CRLF
EndIf
Next
FileWrite("test.txt", $out)
Func _GetModuleFileNameEx($_Pid)
$_Hwnd = DllCall("Kernel32.dll", "hwnd", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $_Pid)
$_Return = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "hwnd", $_Hwnd, "long", 0, "str", 0, "long", 255)
DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $_Hwnd)
If StringInStr($_Return, "\") Then Return $_Return
Return ""
EndFunc ;==>_GetModuleFileNameEx 感谢 可以了 谢谢
页:
[1]