标题:API 取进程名,错误代码 299 怎么解决
取消只看楼主
Ez330阿牛
Rank: 2
等 级:论坛游民
帖 子:42
专家分:14
注 册:2014-3-5
结帖率:11.11%
已结贴  问题点数:5 回复次数:0 
API 取进程名,错误代码 299 怎么解决
程序代码:
  Dim ModuleMsg As API声明.MODULEENTRY32, hSnapShot As Long
        hSnapShot = API声明.CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID)  '建立进程快照
        If hSnapShot > 0 Then
            API声明.CopyMemory_Long ModuleMsg.dwSize, Len(ModuleMsg), 4
            If API声明.Module32First(hSnapShot, ModuleMsg) > 0 Then '获取模块信息
                With ModuleMsg
                    GetPoocessOfByPId = .szModule
                End With
            End If
        End If
        Debug.Print API声明.GetLastError
        API声明.CloseHandle hSnapShot


程序代码:
Public Function GetProcessPathByProcessID(PID As Long) As String
    On Error GoTo Z
    Dim cbNeeded As Long
    Dim szBuf(1 To 250) As Long
    Dim Ret As Long
    Dim szPathName As String
    Dim nSize As Long
    Dim hProcess As Long
    hProcess = OpenProcess(&H400 Or &H10, 0, PID)
    If hProcess <> 0 Then
        Ret = EnumProcessModules(hProcess, szBuf(1), 250, cbNeeded)
        
        If Ret <> 0 Then
            Debug.Print GetLastError, "e"
            szPathName = Space(260)
            nSize = 500
            Ret = GetModuleFileNameExA(hProcess, szBuf(1), szPathName, nSize)
            GetProcessPathByProcessID = Left(szPathName, Ret)
        End If
    End If
    Ret = CloseHandle(hProcess)
    If GetProcessPathByProcessID = "" Then
        Debug.Print GetLastError
        GetProcessPathByProcessID = "SYSTEM"
    End If
    Exit Function
Z:
End Function

我用了两种不同的办法,取进程名,都取不到,而且都是返回 299 ,求解决,我百度不到
搜索更多相关主题的帖子: color 
2014-09-27 14:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-436654-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.127499 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved