Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/04/2015, 06:36
el__tamer
 
Fecha de Ingreso: diciembre-2013
Mensajes: 81
Antigüedad: 10 años, 10 meses
Puntos: 1
Como saber si un .exe de 64 bits se esta ejecuantando

hola, tengo este código de visual basic 6
me funciona perfecto, pero solo funciona para 32 bits y no para 64 bits

Código vb:
Ver original
  1. Option Explicit
  2. Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  3. Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  4. Private Declare Function EnumProcesses Lib "PSAPI.DLL" (lpidProcess As Long, ByVal cb As Long, cbNeeded As Long) As Long
  5. Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess As Long, lphModule As Long, ByVal cb As Long, lpcbNeeded As Long) As Long
  6. Private Declare Function GetModuleBaseName Lib "PSAPI.DLL" Alias "GetModuleBaseNameA" (ByVal hProcess As Long, ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long
  7. Private Const PROCESS_VM_READ = &H10
  8. Private Const PROCESS_QUERY_INFORMATION = &H400
  9.  
  10. Private Function EstaCorriendo(ByVal NombreDelProceso As String) As Boolean
  11.     Const MAX_PATH As Long = 260
  12.     Dim lProcesses() As Long, lModules() As Long, N As Long, lRet As Long, hProcess As Long
  13.     Dim sName As String
  14.     NombreDelProceso = UCase$(NombreDelProceso)
  15.     ReDim lProcesses(1023) As Long
  16.  
  17.     If EnumProcesses(lProcesses(0), 1024 * 4, lRet) Then
  18.         For N = 0 To (lRet \ 4) - 1
  19.             hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, lProcesses(N))
  20.             If hProcess Then
  21.                 ReDim lModules(1023)
  22.                 If EnumProcessModules(hProcess, lModules(0), 1024 * 4, lRet) Then
  23.                     sName = String$(MAX_PATH, vbNullChar)
  24.                     GetModuleBaseName hProcess, lModules(0), sName, MAX_PATH
  25.                     sName = Left$(sName, InStr(sName, vbNullChar) - 1)
  26.  
  27.                     If Len(sName) = Len(NombreDelProceso) Then
  28.                         If NombreDelProceso = UCase$(sName) Then EstaCorriendo = True: Exit Function
  29.                     End If
  30.                 End If
  31.             End If
  32.             CloseHandle hProcess
  33.         Next N
  34.     End If
  35. End Function
  36.  
  37. Private Sub Command1_Click()
  38.     If EstaCorriendo("DTEPlanoWS.exe") Then
  39.          MsgBox "El programa está en ejecución"
  40.     Else
  41.          MsgBox "El programa NO está en ejecución"
  42.     End If
  43. End Sub