找回密码
 加入
搜索
查看: 2969|回复: 2

[系统综合] 如何获取几个进程的路径并写入到文件啊[已解决]

[复制链接]
发表于 2010-8-12 22:50:34 | 显示全部楼层 |阅读模式
本帖最后由 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[0][0]
                If $var[$i][1] = "1" Then
                        ProcessExists($var[$i][0])
       $iPid=ProcessExists($var[$i][0])

                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[0],"long",0,"str",0,"long",255)        
        DllCall("Kernel32.dll","int","CloseHandle","hwnd",$_Hwnd[0])        
        If StringInStr($_Return[3],"\") Then Return $_Return[3]
        Return ""
            EndFunc

       
高手指导哈谢谢
发表于 2010-8-12 23:08:13 | 显示全部楼层
FileChangeDir(@ScriptDir)
Dim $var = IniReadSection("setcfg.ini", "进程")
If @error Then Exit MsgBox(16, "错误", "请检查“setcfg.ini”是否存在或配置是否正确!")
Dim $out
For $i = 1 To $var[0][0]
        If $var[$i][1] = "1" Then
                $iPid = ProcessExists($var[$i][0])
                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[0], "long", 0, "str", 0, "long", 255)
        DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $_Hwnd[0])
        If StringInStr($_Return[3], "") Then Return $_Return[3]
        Return ""
EndFunc   ;==>_GetModuleFileNameEx
 楼主| 发表于 2010-8-12 23:12:57 | 显示全部楼层
感谢 可以了 谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-2 16:05 , Processed in 0.075114 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表