Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Starting Other Applications

Posted on 1997-07-14
4
Medium Priority
?
146 Views
Last Modified: 2010-04-06
I can't beleive this is so complicated in Delphi.  I simply want to start another application, not necesarily for OLE or DDE puposes.  In Paradox, I simply put 'Execute.notepad.exe' in a button - and it happened.  I tried CreateProcess and WinExec and neither work.  Can someone write so CODE telling me how to execute an .exe file.  

I'll assume your code will search the existing directory for the .exe, then the PATH, then the entire drive.  If this is not the case, please let me know what the code is to do this.
0
Comment
Question by:d4jaj1
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 60 total points
ID: 1338831
It's not harder to do than this:
(You just have to tell the system how the application's
supposed to be shown)

WinExec('notepad.exe', SW_SHOWNORMAL);

...OR...

uses ShellAPI;
   .
   .
   .
ShellExecute(Handle, 'open', 'notepad.exe', '', '', SW_SHOWNORMAL);

/// John

0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1338832
Thanks, it works great!  I'm going to rate you Excellent on this, but I wanted to make sure this would search teh current directory, then windows directory, or all drives on the user's system?  

The reason I'm asking is the user will be able to install some files where ever thhey want, thus my program would need to search for it.
0
 
LVL 3

Author Comment

by:d4jaj1
ID: 1338833
I'll assume either you didn't have time or didn't know teh answer to my clairification answer.
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1338834
Sorry, I didn't realize that it was a question.
These methods scan directories like this (taken from the help file):

1.      The directory from which the application loaded.
2.      The current directory.
3.      The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
4.      The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
5.      The directories listed in the PATH environment variable.

If you need to scan any arbitrary directory, you have to scan
that yourself, preferrably with a recursive function using
"FindFirst/Next/Close". But if you do; ask a formal question
so that the experts here get some more points. :-)

/// John

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

886 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