Solved

Starting Other Applications

Posted on 1997-07-14
4
138 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 20 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

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

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

24 Experts available now in Live!

Get 1:1 Help Now