Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Sintaxis de ShellExecuteEx (https://www.clubdelphi.com/foros/showthread.php?t=87188)

JuanOrtega 25-11-2014 23:50:11

Sintaxis de ShellExecuteEx
 
Hola estoy buscando la sintaxis de la funcion ShellExecuteEx y no la encuentro en google ,estoy tratando de usar la misma funcion ShellExecute a ShellExecuteEx pero me da error.

El codigo :

Código Delphi [-]
    ShellExecute(0, 'open', PChar('c:/xampp/htdocs/t.jpg'), nil, nil,
      SW_SHOWNORMAL);

    ShellExecuteEx(0, 'open', PChar('c:/xampp/htdocs/test.jpg'), nil, nil,
      SW_SHOWNORMAL);

El error :

Código Delphi [-]
[DCC Error] test.dpr(15): E2034 Too many actual parameters

¿ Que estoy haciendo mal en la sintaxis ?

ecfisa 26-11-2014 02:23:53

Hola Lepuke.

La sintáxis podes encontrarla aquí: ShellExecuteEx function

Un ejemplo de uso en Delphi:
Código Delphi [-]
...
implementation

uses ShellApi;

procedure OpenJPG(const aName: TFileName);
var
  ExecInfo: SHELLEXECUTEINFO;
begin
  ZeroMemory(@ExecInfo, SizeOf(SHELLEXECUTEINFO));
  ExecInfo.cbSize := SizeOf(SHELLEXECUTEINFO);
  ExecInfo.fMask  := SEE_MASK_NOCLOSEPROCESS;
  ExecInfo.Wnd    := 0;
  ExecInfo.lpVerb := 'open';
  ExecInfo.lpFile := PChar(aName);
 // pExecInfo.lpParameters := ...
  ExecInfo.nShow  := SW_SHOWNORMAL;
  if not ShellExecuteEx(@ExecInfo) then
    if GetLastError <= 32 then
      SysErrorMessage(GetLastError)
end;

// Uso:
procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenJPG('C:\imagen.jpg');
end;

Saludos :)

JuanOrtega 26-11-2014 17:58:15

Funciona perfecto ,gracias por la ayuda.

JuanOrtega 13-04-2016 20:55:00

Perdon ecfisa por responder un tema viejo pero queria preguntarte como seria esta funcion para realizar el comando : print d:/test.txt , que es para imprimir.

Las lineas que cambie son :

Código Delphi [-]
ExecInfo.lpFile := 'print';
ExecInfo.lpParameters := 'd:/test.txt';
ExecInfo.lpVerb := '';

¿ Puse mal los parametros ?

ecfisa 13-04-2016 22:06:05

Hola.

Intenta de este modo:
Código Delphi [-]
uses ShellApi;

....
var
  ExecInfo: SHELLEXECUTEINFO;
begin
  ZeroMemory(@ExecInfo, SizeOf(SHELLEXECUTEINFO));
  ExecInfo.cbSize := SizeOf(SHELLEXECUTEINFO);
  ExecInfo.fMask  := SEE_MASK_NOCLOSEPROCESS;
  ExecInfo.Wnd    := 0;
  ExecInfo.lpVerb := 'print';  // acción a realizar
  ExecInfo.lpFile := 'C:\Nombre_Carpeta\Nombre_Archivo.txt';  // ruta+archivo a imprimir
  ExecInfo.lpParameters := '';
  ExecInfo.nShow        := SW_SHOWNORMAL;
  if not ShellExecuteEx(@ExecInfo) then
    if GetLastError <= 32 then
      SysErrorMessage(GetLastError)
end;

Saludos :)

Casimiro Notevi 27-07-2016 00:55:30

Esto no tiene nada que ver con el tema, crea un hilo nuevo, gracias.

Cita:

Empezado por Lepuke (Mensaje 507204)
Hola


JuanOrtega 27-07-2016 01:47:06

Es la misma funcion y el mismo codigo pero bueno ahora creo un nuevo tema , gracias por borrar el mensaje.

Casimiro Notevi 27-07-2016 10:29:25

Cita:

Empezado por Lepuke
cuando cargo un archivo cualquiera que estan ocultos ya sea una imagen o cualquier programa carga la imagen bien pero despues de eso tilda toda la aplicacion ya sea grafica o consola , eh estado haciendo pruebas y solo pasa cuando el archivo esta oculto

Obviamente, no tiene nada que ver, aunque ambos casos sean un coche de cuatro ruedas y de color rojo, pero en uno es cómo se usa, y en tu caso es un problema puntual con el motor.
Gracias :)


La franja horaria es GMT +2. Ahora son las 12:23:54.

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