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 30-11-2011
Anel Hernandez Anel Hernandez is offline
Miembro
 
Registrado: mar 2005
Posts: 94
Poder: 20
Anel Hernandez Va por buen camino
vez con ShellExecuteEx

Hola,

Estoy mandando a ejecutar un programa con varios parametros de forma consecutiva de esta forma:
Código Delphi [-]
var
  Info:TShellExecuteInfo;
begin
  with Info do begin
   cbSize := SizeOf(ShellExecuteInfo);
   fMask := SEE_MASK_NOCLOSEPROCESS;
   Wnd := Handle;
   lpVerb := 'open';
   lpFile := PChar('C:\Archivos de programa\programa\programa.exe');
   lpParameters := PChar(Listbox1.items.Strings[i-1]);
   lpDirectory := PChar('D:\');
   nShow := SW_SHOW;
  end;
  Mandar a ejecutar varios programas a la(@INFO);

Pero necesito mandar N a la vez y luego cuando termine 1 mandar a ejecutar el siguiente de la lista de modo que siempre tenga en ejecucion N hasta que se termine la lista y vayan quedando N, N-1, N-2,..., 3,2,1. y finaliza.

como pudiera organizar esto?

gracias
Responder Con Cita
  #2  
Antiguo 30-11-2011
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.282
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
Tal vez utilizando Threads.
En ese caso sólo tienes que controlar en número de threads abiertos.
__________________
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
  #3  
Antiguo 30-11-2011
Anel Hernandez Anel Hernandez is offline
Miembro
 
Registrado: mar 2005
Posts: 94
Poder: 20
Anel Hernandez Va por buen camino
Parece ke cometi un error de copiado en el mensaje original. Rectifico:
Código Delphi [-]
var
 i:integer;
 Info:TShellExecuteInfo;
begin
 for i:=1 to stringgrid6.RowCount-1 do begin
   with Info do begin
    cbSize := SizeOf(ShellExecuteInfo);
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Handle;
    lpVerb := 'open';
    lpFile := PChar(DirT+'Calmetl.exe');
    lpParameters := PChar(checklistbox1.items.Strings[i-1]);
    lpDirectory := PChar(dirT);
    nShow := SW_SHOW;
   end;
   ShellExecuteEx(@INFO);
   Repeat
    Application.ProcessMessages;
   until WaitForSingleObject( Info.hProcess,500)<> WAIT_TIMEOUT;

end;


no hay manera, por esta via, de controlar/gestionar cuantos programas hay corriendo?
Responder Con Cita
  #4  
Antiguo 30-11-2011
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Poder: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Mira esto:

Código Delphi [-]
{Execute a program and wait until it has finished. The following example uses the ShellExecuteEx API function.}

 // Execute the Windows Calculator and pop up
 // a message when the Calc is terminated.
 uses ShellApi;
 ...
 var
    SEInfo: TShellExecuteInfo;
    ExitCode: DWORD;
    ExecuteFile, ParamString, StartInString: string;
 begin
    ExecuteFile:='c:\Windows\Calc.exe';
 
    FillChar(SEInfo, SizeOf(SEInfo), 0) ;
    SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
    with SEInfo do begin
      fMask := SEE_MASK_NOCLOSEPROCESS;
      Wnd := Application.Handle;
      lpFile := PChar(ExecuteFile) ;
 {
 ParamString can contain the
 application parameters.
 }
 // lpParameters := PChar(ParamString) ;
 {
 StartInString specifies the
 name of the working directory.
 If ommited, the current directory is used.
 }
 // lpDirectory := PChar(StartInString) ;
      nShow := SW_SHOWNORMAL;
    end;
    if ShellExecuteEx(@SEInfo) then begin
      repeat
        Application.ProcessMessages;
        GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
      until (ExitCode <> STILL_ACTIVE) or
    Application.Terminated;
      ShowMessage('Calculator terminated') ;
    end
    else ShowMessage('Error starting Calc!') ;
 end;
Responder Con Cita
  #5  
Antiguo 17-01-2012
Anel Hernandez Anel Hernandez is offline
Miembro
 
Registrado: mar 2005
Posts: 94
Poder: 20
Anel Hernandez Va por buen camino
Hola,

resolvi haciendo un ciclo que comprueba todos los procesos lanzadosÑ
Código Delphi [-]
GetExitcodeProcess(h[k],ExitCode);
if exitCode<>STILL_ACTIVE then  begin

pudiera hacerse lo ke kiero con WaitForMultipleObjects()?????

gracias
Responder Con Cita
  #6  
Antiguo 19-01-2012
Delfino Delfino is offline
Miembro
 
Registrado: jul 2003
Ubicación: Madrid
Posts: 974
Poder: 21
Delfino Va por buen camino
Lo hago asi
Código Delphi [-]
function ExecWait(ExeFile, Params: string): Boolean;   //  Synchronous ShellExecute
  var SEInfo: TShellExecuteInfo;
      ExitCode: DWORD;
begin
  FillChar(SEInfo, SizeOf(SEInfo), 0) ;
  SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
  with SEInfo do
  begin
   fMask := SEE_MASK_NOCLOSEPROCESS;
   Wnd := Application.Handle;
   lpFile := PChar(ExeFile) ;
   lpParameters := PChar(Params) ;
   lpDirectory := 'C:\' ;
   nShow := SW_HIDE;
  end;
  if ShellExecuteEx(@SEInfo) then
  begin
   repeat
    Application.ProcessMessages;
    GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
   until (ExitCode <> STILL_ACTIVE) or (Application.Terminated);
   Result := True;
  end
  else
   Result := False;
end;
__________________
¿Microsoft? No, gracias..
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
Devolver Foco a una aplicación creada con ShellExecuteEx gluglu API de Windows 4 29-04-2011 22:10:46
uso shellExecute o shellExecuteEx alfil123 Varios 2 09-02-2008 04:30:16


La franja horaria es GMT +2. Ahora son las 12:49:51.


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