Solved

Running app.

Posted on 2001-07-29
4
139 Views
Last Modified: 2010-04-06
How do you run another app. that is within your current app. exe folder and error check if it is?
Or how do you runn it if it is in a folder within your current app.exe folder?
0
Comment
Question by:Enej
  • 3
4 Comments
 
LVL 22

Expert Comment

by:mnasman
ID: 6330880
Hello

  use shellapi to run the application, it will use the folder u r running ur program from as current folder and check about the file using FileExists

I hope that what are you looking for

Uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if FileExists('test.exe') then
    ShellExecute(handle,'open','test.exe',nil,nil,SW_ShowNormal)
  else
    ShowMessage('This file is not exist in the current folder');
end;

Mohammed
0
 
LVL 22

Accepted Solution

by:
mnasman earned 50 total points
ID: 6330889
Hello

  for better coding, use ExtractFilePath funcation tp get the folder for ur application that running.

uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
var
  Path : String;
begin
  Path := ExtractFilePath(Application.ExeName);
  if FileExists(Path + 'test.exe') then
    ShellExecute(handle,'open',Pchar(Path + 'test.exe'),nil,nil,SW_ShowNormal)
  else
    ShowMessage('This file is not exist in the current folder');
end;

if you want to run a program within ur current folder just add this folder to the path string like :

  Path := ExtractFilePath(Application.ExeName) + 'test folder\';

Best regards
Mohammed Nasman


0
 

Author Comment

by:Enej
ID: 6330964
SellamAlleikum Mohammed,
It works OK .Thanks!
0
 
LVL 22

Expert Comment

by:mnasman
ID: 6331080
wa alikum alsalam
I'm happy that's work with you :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now