Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 20-09-2015
deliriun deliriun is offline
Miembro
 
Registrado: ago 2014
Posts: 51
Poder: 10
deliriun Va por buen camino
Question Detectar si un proceso esta activo.

Hola qué tal?
Quisiera saber si hay la posibilidad de verificar si un proceso esta activo o corriendo...

Por ejemplo si el Bloc de Notas esta activo que de un mensaje.

He buscado otros ejemplos pero ninguno me funciona...

De antemano gracias.
Responder Con Cita
  #2  
Antiguo 21-09-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Poder: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola deliriun.

Proba de este modo,
Código Delphi [-]
uses tlhelp32;

function IsAppRunning(const ExeFileName: string): Boolean;
var
  Entry: PROCESSENTRY32;
  hSnapShot: THandle;
begin
  hSnapShot:= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  Entry.dwSize:= SizeOf(PROCESSENTRY32);

  Result:= False;
  if Process32First(hSnapShot, Entry) then
    while Process32Next(hSnapShot, Entry) and not Result do
      if Entry.szExeFile = ExeFileName then
        Result:= True;
  CloseHandle(hSnapSHot);
end;

Ejemplo de uso:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsAppRunning('notepad.exe') then
    ShowMessage('Se está ejecutando')
  else
    ShowMessage('No se está ejecutando');
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita
  #3  
Antiguo 21-09-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Poder: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Si te interesa saber si un proceso de 16 bits se ejecuta, sigue este hilo en C/C++.

En delphi:
Código Delphi [-]
function VDMEnumTaskWOWEx(dwProcessId: DWORD; fp: pointer; lparam: integer): integer; stdcall; external 'VdmDbg.dll' name 'VDMEnumTaskWOWEx';
function VDMEnumProcessWOW(fp: pointer; lparam: integer): integer; stdcall; external 'VdmDbg.dll' name 'VDMEnumProcessWOW';

type
TRuningProcess16 = record
  Name: Pchar;
  Running: boolean;
end;
PTRuningProcess16 = ^TRuningProcess16;


// Enumera procesos
function ProcessTasks(dwThreadId: DWORD; hMod16, hTask16: WORD; pszModName, pszFileName: PCHAR; PE: integer): boolean; stdcall;
begin
   if AnsiContainsText(pszFileName, PTRuningProcess16(PE).Name) then
   begin
      PTRuningProcess16(PE).Running:= true;
      Result:= true;
      exit;
   end;
   Result:= false;
end;

// Enumera Máquinas Virtuales
function ProcessVDMs(dwProcessId, dwAttrib: DWORD; PE: integer): boolean; stdcall;
begin
   VDMEnumTaskWOWEx(dwProcessId, @ProcessTasks, PE);
   Result:= PTRuningProcess16(PE).Running;
end;

function IsRunning16_(Name: string): boolean;
var
  PE: TRuningProcess16;
begin
  PE.Name:= PCHAR(Name);
  PE.Running:= false;

  // Buscando...
  VDMEnumProcessWOW(@ProcessVDMs, integer(@PE));
  Result:= PE.Running;
end;

Combinar una llamada al código de ecfisa, con otra a sRunning16_:

Código Delphi [-]
IsRunin16_32(ExeFileName: String): BOOL;
begin
  Result:= IsAppRunning(ExeFileName) or IsRunning16_(ExeFileName);
end;

Saludos.
Responder Con Cita
  #4  
Antiguo 22-09-2015
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.286
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Se supone que también podrías hacerlo utilizando la función FindWindows (si buscas en el clubdelphpi encontrarás muchos hilos al respecto) o también mediante WMI (link).
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Detectar proceso en ejecucion C++ dmartinezn C++ Builder 6 28-08-2012 22:07:16
Saber si un proceso esta activo Anel Hernandez Varios 3 17-01-2012 19:17:16
Detectar proceso Saindoft API de Windows 6 07-01-2009 00:13:37
Detectar usuario activo??? trohan Redes 1 24-01-2008 19:26:29
¿Cómo detectar el usuario activo? Neftali [Germán.Estévez] Trucos 1 28-12-2007 17:48:48


La franja horaria es GMT +2. Ahora son las 20:44:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi