Board index » delphi » NEED EMERGENCY HELP!!!

NEED EMERGENCY HELP!!!

Have to Have App Out Today!!!  Can someone email
me an example of how to shell out and run another
application...  I keep trying

ShellExecute("C:\TEMP\APP.EXE"); and have the
SHELLAPI unit added to the project.  I just
can't seem to get it to work!!!

Thanks in Advance !!!!

Kelton

 

Re:NEED EMERGENCY HELP!!!


Quote
> In article <3468B341.CD54B...@ix.netcom.com>,
> Kelton Averyt <ave...@ix.netcom.com> wrote:
> >Have to Have App Out Today!!!  Can someone email
> >me an example of how to shell out and run another
> >application...  I keep trying

> >ShellExecute("C:\TEMP\APP.EXE"); and have the
> >SHELLAPI unit added to the project.  I just
> >can't seem to get it to work!!!

_________________________________________

The following works. Change the bits you need to and paste it.

Regards ...

procedure TfMain.mToolsWinMixersClick(Sender: TObject);
var
  zFileName, zParams: array[0..79] of Char;
begin
  try
    ShellExecute(Application.MainForm.Handle, nil,
      StrPCopy(zFileName, ExtractFilePath(Application.ExeName)[1] +
      ':\WINDOWS\SNDVOL32.EXE'), StrPCopy(zParams, ''), '', SW_SHOW);
  except
  end;
end;
_________________________________________

  ?  Leigh Harrison      
  ?  tel +64 6 343 2671
  ?  fax +64 6 343 2649
  ?  mobile 025 933 913
  ?  email le...@radiOshop.co.nz
  ?  3 Iris Place Wanganui New Zealand
_________________________________________
                             radiOshop

Re:NEED EMERGENCY HELP!!!


In article <3468B341.CD54B...@ix.netcom.com>,

Quote
Kelton Averyt <ave...@ix.netcom.com> wrote:
>Have to Have App Out Today!!!  Can someone email
>me an example of how to shell out and run another
>application...  I keep trying

>ShellExecute("C:\TEMP\APP.EXE"); and have the
>SHELLAPI unit added to the project.  I just
>can't seem to get it to work!!!

I don't have exact experience with this, but I checked up the Win32.hlp file.

HINSTANCE ShellExecute(
  HWND  hwnd,     // handle to parent window
  LPCTSTR  lpOperation, // pointer to string that specifies operation to perform
  LPCTSTR  lpFile,  // pointer to filename string
  LPTSTR  lpParameters,   // pointer to string that specifies executable-file parameters
  LPCTSTR  lpDirectory,    // pointer to string that specifies default directory
  INT  nShowCmd   // whether file is shown when opened
);

It does look a bit different from your code...

--
|| Bjorn K. Nilssen      // http://home.sn.no/~bjoernk/  // mainly 3D ||

Re:NEED EMERGENCY HELP!!!


  Take a look at the following.  It uses the ExecuteFile() function that
can be found in the FMXUtils.pas file that came in the Demos\Doc\Filemanex
directory with Delphi 1.0 and 2.0.  ExecuteFile() is basically just a
wrapper for the ShellExecute() function so this shows how to convert the
params from pascal for use with it.

implementation

{$R *.DFM}

uses
  ShellAPI;

function ExecuteFile(const FileName, Params, DefaultDir: string;
  ShowCmd: Integer): THandle;
var
  zFileName, zParams, zDir: array[0..79] of Char;
begin
  Result := ShellExecute(Application.MainForm.Handle, nil,
    StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
    StrPCopy(zDir, DefaultDir), ShowCmd);
end;

To use it do something like:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ExecuteFile('C:\WINDOWS\NOTEPAD.EXE','','',SW_SHOW);
end;

This will fire up the the Notepad.  Or:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ExecuteFile('C:\WINDOWS\NOTEPAD.EXE','C:\Myfiles\test.txt','',SW_SHOW);
end;

This will fire up the the Notepad and pass it the command line parameter
C:\Myfiles\test.txt which it will open.

Hope this helps!
--

Rodney E Geraghty
GERA-Tech
Ottawa, Canada
gera...@ibm.net

Bjorn-Kare Nilssen <bjoe...@sn.no> wrote in article
<qANa0gmCgIXY09...@sn.no>...

Quote
> In article <3468B341.CD54B...@ix.netcom.com>,
> Kelton Averyt <ave...@ix.netcom.com> wrote:
> >Have to Have App Out Today!!!  Can someone email
> >me an example of how to shell out and run another
> >application...  I keep trying

> >ShellExecute("C:\TEMP\APP.EXE"); and have the
> >SHELLAPI unit added to the project.  I just
> >can't seem to get it to work!!!

> I don't have exact experience with this, but I checked up the Win32.hlp
file.

> HINSTANCE ShellExecute(
>   HWND  hwnd,     // handle to parent window
>   LPCTSTR  lpOperation, // pointer to string that specifies operation to
perform
>   LPCTSTR  lpFile,  // pointer to filename string
>   LPTSTR  lpParameters,   // pointer to string that specifies

executable-file parameters

- Show quoted text -

Quote
>   LPCTSTR  lpDirectory,    // pointer to string that specifies default
directory
>   INT  nShowCmd   // whether file is shown when opened
> );

> It does look a bit different from your code...

> --
> || Bjorn K. Nilssen      // http://home.sn.no/~bjoernk/  // mainly 3D ||

Other Threads