我想在a.exe中检测到正在执行的应用程序b.exe的所在路径,不知道该如何检测,还请各位大侠帮忙。

解决方案 »

  1.   

    如果应用程序b.exe是安装在系统中,可以通过读注册表解决,否则无法实现
      

  2.   

    应用程序b.exe是按装在系统中的,那该如何读取注册表,能否提供这方面的实列,谢谢!
      

  3.   

    用toolhelp函数得到系统快照FAQ里有
      

  4.   

    正确的答案来了:
    看看这篇文章吧
    http://expert.csdn.net/Expert/topic/2084/2084976.xml?temp=.4029657
      

  5.   

    看看这篇文章吧:
    http://expert.csdn.net/Expert/topic/2084/2084976.xml?temp=.2942163
    问题可以解决了吧。
      

  6.   

    Process32First Process32Next 不行.用Moudle32First Moudle32Next MOUDLEENTRY32结构可以在MSDN里,或者VC里查出来.用法就差不多,程序结构也差不多了
      

  7.   

    lprocessid是process的id,exename是程序的名字,fqexename是程序的全路径,priority是process的优先级。
    Public Sub GetProcessInfo(ByVal lProcessId As Long, ExeName As String, FQExeName As String, Priority As Long)
    Dim hProcess As Long
    Dim sExeName As String, sFQExeName As String, lPriority As Long
    Dim hExe As Long
    Dim cbNeeded As Long
    Dim lret As Long
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, _
          0&, _
          lProcessId)
          
        Select Case lProcessId
        Case 0   ' System Idle Process
             sExeName = "Idle Process"
             sFQExeName = "Idle Process"
        Case 2
             sExeName = "System"
             sFQExeName = "System"
        Case 28
             sExeName = "csrss.exe (Win32)"
             sFQExeName = "csrss.exe (Win32)"
        End Select
        
             
        If hProcess <> 0 Then
       
          ' Now get the handle of the first module
          ' in this process, since first module is EXE
          hExe = 0
          lret = EnumProcessModules(hProcess, hExe, 4&, cbNeeded)
          
          If hExe <> 0 Then
          
             ' Get the name of the module
             sExeName = String$(MAX_PATH, 0)
             lret = GetModuleBaseName(hProcess, hExe, sExeName, Len(sExeName))
             sExeName = Trim0(sExeName)
             
             ' Get full path name
             sFQExeName = String$(MAX_PATH, 0)
             lret = GetModuleFileNameEx(hProcess, hExe, sFQExeName, Len(sFQExeName))
             sFQExeName = Trim0(sFQExeName)
             
             ' Get priority
             lPriority = GetPriorityClass(hProcess)
             
          
          End If   ' EXE <> 0
       
       End If      ' hProcess <> 0
       ExeName = sExeName
       FQExeName = sFQExeName
       Priority = lPriority
       
       ' Close handle
       lret = CloseHandle(hProcess)
       
    End SubPrivate Function Trim0(sName As String) As String' Keep left portion of string sName up to first 0. Useful with Win API null terminated strings.Dim x As Integer
    x = InStr(sName, Chr$(0))
    If x > 0 Then Trim0 = Left$(sName, x - 1) Else Trim0 = sNameEnd Function
      

  8.   

    Private Const MAX_PATH = 260
    其他的api自己加。
      

  9.   

    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION _
                   Or PROCESS_VM_READ, 0, ProcessIDs(i))
                'Got a Process handle
                If hProcess <> 0 Then
                    'Get an array of the module handles for the specified
                    'process
                    lRet = EnumProcessModules(hProcess, Modules(1), 200, _
                                                 cbNeeded2)
                    'If the Module Array is retrieved, Get the ModuleFileName
                    If lRet <> 0 Then
                       ModuleName = Space(MAX_PATH)
                       nSize = 500
                       lRet = GetModuleFileNameExA(hProcess, Modules(1), _
                                       ModuleName, nSize)                  messagebox Modulename