Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Go Back   Foros Club Delphi > Principal > API de Windows
Register FAQ Members List Calendar Guía de estilo Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24/01/2007
Diego9 Diego9 is offline
Miembro
 
Join Date: Jan 2007
Posts: 10
Poder: 0
Diego9 Va por buen camino
Ejecutar Archivo

Buenas Noches

Para ejecutar un archivo utilizo

Código Delphi [-]
ShellExecute(MiForm.Handle,nil,('c:\Miarchivo.extension'),'','',SW_Shownormal);

Pero si este archivo no siempre va a ser el mismo y voy a coger la ruta y el archivo de un cuadro de dialogo, ¿como puedo hacerlo?.

Gracias
Reply With Quote
  #2  
Old 24/01/2007
dec's Avatar
dec dec is offline
Moderador
 
Join Date: Dec 2004
Location: Alcobendas, Madrid, España
Posts: 13,142
Poder: 36
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Siempre puedes utilizar variables:

Código Delphi [-]
var
  rutaArchivo: string;
begin
  rutaArchivo := 'C:\unarchivo.txt';
  ShellExecute(MiForm.Handle, 'open', PChar(rutaArchivo),nil,nil,SW_SHOWNORMAL);
end;

Ahora tienes que investigar sobre el uso de un "TOpenDialog", pero, en definitiva, ya sabes que puedes guardar la elección del usuario en la variable "rutaArchivo", por ponerte un ejemplo, de modo que luego puedas usarla en la función "ShellExecute".

Una posible forma de hacerlo:

Código Delphi [-]
begin
  with TOpenDialog.Create(Self) do
  begin
    if Execute then
    begin
      ShellExecute(Self.Handle, 'open', PChar(FileName), nil, nil, SW_SHOWNORMAL);
    end;
    Free;
  end;

Otra posible forma:

Código Delphi [-]
var
  dlg: TOpenDialog;
begin
  dlg := TOpenDialog.Create(Self);
  try
    if dlg.Execute then
      ShellExecute(Self.Handle, 'open',
       PChar(dlg.FileName), nil, nil, SW_SHOWNORMAL);
  finally
    dlg.Free;
  end;
end;

Y aún otra más:

Código Delphi [-]
begin
  if OpenDialog1.Execute then
  begin
    ShellExecute(Self.Handle, 'open',
      PChar(OpenDialog1.FileName), nil, nil, SW_SHOWNORMAL);
  end;
end;
__________________
David Esperalta
www.decsoftutils.com
Reply With Quote
  #3  
Old 24/01/2007
Diego9 Diego9 is offline
Miembro
 
Join Date: Jan 2007
Posts: 10
Poder: 0
Diego9 Va por buen camino
Smile

Gracias David me has alegrado la noche, funciona correctamente.
Saludos,
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ejecutar un archivo .asp en un activeX escullar Internet 0 16/05/2006 11:24
Ejecutar un Archivo de Java (.jar) maravert JAVA 2 12/10/2004 17:31
ejecutar archivo y esperar que termine agustincs API de Windows 4 18/08/2004 22:53
Ejecutar archivo .hlp ¥0n1 API de Windows 1 22/01/2004 18:36
Ejecutar Sql A Partir De Un Archivo Guillermo SQL 4 17/07/2003 19:04


All times are GMT +2. The time now is 01:52.


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