Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 10-03-2015
JuanOrtega JuanOrtega is offline
Miembro
NULL
 
Registrado: sep 2011
Posts: 130
Poder: 13
JuanOrtega Va por buen camino
Ejecutar comando en Delphi con ShellExecute

Hola tengo la siguiente linea codigo :

Código Delphi [-]
  ShellExecute(0, 'open',
    PChar('wget --no-check-certificate --user-agent="user agent" -E -H -k -K -p https://www.probando.com'), nil, nil, SW_SHOWNORMAL);

El problema es que siempre me dice "Unterminated string" , intente usando las comillas doble por separado pero sigue dando error , el codigo de las comillas dobles funcionales queda asi :

Código Delphi [-]
 
 ShellExecute(0, 'open',
    PChar('wget --no-check-certificate --user-agent='+'"'+'user agent'+'"'+' -E -H -k -K -p https://www.probando.com
    '), nil, nil, SW_SHOWNORMAL);

En este codigo el problema es desde los guiones en adelante con el mismo error "Unterminated string" , por ejemplo de c# esto se solucionaba con @ pero en este caso no se como resolver este problema.

¿ Alguien puede ayudarme ?
Responder Con Cita
  #2  
Antiguo 10-03-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Lepuke,

Cita:
Empezado por Lepuke
...El problema es que siempre me dice "Unterminated string" (En tiempo de compilación)...desde los guiones en adelante...


Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ShellAPI, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   Command : String;
   Parameters : String;

begin
   Command := 'wget';
   Parameters := '--no-check-certificate --user-agent=' + '"' + 'user agent' + '"' + ' -E -H -k -K -p https://www.probando.com';
   ShellExecute(Handle, nil, PChar(Command) , PChar(Parameters), nil, SW_SHOWNORMAL);
end;

end.
El código anterior en Delphi 7 sobre Windows 7 x32, compila sin ningún mensaje de error.

Revisa esta información:
Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 10-03-2015 a las 23:55:02.
Responder Con Cita
  #3  
Antiguo 11-03-2015
JuanOrtega JuanOrtega is offline
Miembro
NULL
 
Registrado: sep 2011
Posts: 130
Poder: 13
JuanOrtega Va por buen camino
hola , gracias por la ayuda el codigo funciona bien pero a veces me parece que ya no detecta los parametros , me refiero a que por momentos solo hace wget www.probando.com , ¿ eso eso posible o solo me parece xD ?
una pregunta ¿ hay alguna forma de detectar cuando el comando termina porque se me ejecuta todo normal despues del shellexecute ?
Responder Con Cita
  #4  
Antiguo 11-03-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Poder: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Lepuke,

Cita:
Empezado por Lepuke
...el codigo funciona bien pero a veces me parece que ya no detecta los parámetros...¿Eso eso posible?...
El comando ShellExecute ejecuta los comandos externos a Delphi de la misma forma que se ejecutarían manualmente, te sugiero ejecutar el comando vía Shell Command y verificar si este es ejecutado como tu aplicación requiere.

Cita:
Empezado por Lepuke
...¿Hay alguna forma de detectar cuando el comando termina porque se me ejecuta todo normal despues del Shellexecute?...


Revisa esta información:
Cita:
Empezado por Microsoft

ShellExecute function


Return value Type: HINSTANCE

If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below.

Return codeDescription 0 : The operating system is out of memory or resources.
ERROR_FILE_NOT_FOUND : The specified file was not found.
ERROR_PATH_NOT_FOUND : The specified path was not found.
ERROR_BAD_FORMAT : The .exe file is invalid (non-Win32 .exe or error in .exe image).
SE_ERR_ACCESSDENIED : The operating system denied access to the specified file.
SE_ERR_ASSOCINCOMPLETE : The file name association is incomplete or invalid.
SE_ERR_DDEBUSY : The DDE transaction could not be completed because other DDE transactions were being processed.
SE_ERR_DDEFAIL : The DDE transaction failed.
SE_ERR_DDETIMEOUT : The DDE transaction could not be completed because the request timed out.
SE_ERR_DLLNOTFOUND : The specified DLL was not found.
SE_ERR_FNF : The specified file was not found.
SE_ERR_NOASSOC : There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
SE_ERR_OOM : There was not enough memory to complete the operation.
SE_ERR_PNF : The specified path was not found.
SE_ERR_SHARE : A sharing violation occurred.


Tomado de : ShellExecute function
Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 11-03-2015 a las 00:59:53.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

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
Ejecutar comando remoto papulo Linux 5 27-11-2008 18:41:46
Comando "Ejecutar" de Windows XP, desde Delphi BuRtOn Varios 15 25-08-2008 17:07:15
Ejecutar comando del Sistema Operativo sergionr API de Windows 6 09-04-2007 17:52:07
ShellExecute para ejecutar comando que contiene '>' mlara API de Windows 5 26-03-2007 01:25:28
Ejecutar comando runas desde delphi bykram API de Windows 10 29-12-2004 20:29:24


La franja horaria es GMT +2. Ahora son las 18:01:45.


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