I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Object PASCAL Topic   Print This     

Code to launch applications?

Code to launch applications? in Delphi Object PASCAL topic (part of our Pascal and Delphi Coding group).

Quick Search: applications   Code launch   Code launch applications  
Matt Verratti
 (Inactive)
Libertyville, IL
I have searched all through the help files included with Delphi with no luck! I am using Delphi 4 and 5, and what I need to do is pretty simple: I want a button to launch notepad with a specific file.

Can someone either give me a sample of code that does this, or at least point me to a resource that will explain how to do it. Like I said, I searched through all the Delphi help files with no luck, but maybe I was using the wrong terminology.
 Posted 18 years ago (Thread Starter)
Comment Quote
About Matt Verratti -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6497, 4 replies
Thread Started 6/5/2002 8:12:00 AM
View Counter=1716
Location=Libertyville, IL  
Joined=18 years ago   MB Posts=12  
Angel
 (Inactive)
England
Hi, you can launch notepad with something like

ShellExecute (Handle, 'open', 'c:\Windows\notepad.exe', nil, nil, SW_SHOWNORMAL);

If you want to open a specific file then do the following

ShellExecute(Handle,'open','c:\windows\notepad.exe','C:\Doc1.txt', nil, SW_SHOWNORMAL);

Just replace the C:\Doc1 with whatever file you wish to open. Also, dont forget to add 'ShellAPI' to your uses clause for this to work.
 Posted 18 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6501 (Level 1.1)  Reply to 6497
Thread Started 6/5/2002 8:30:00 AM
View Counter=2
Location=England  
Joined=19 years ago   MB Posts=199  
Angel
 (Inactive)
England
You can locate where you program is running from by using the following code.

var
S : String;
begin
S := ExtractFilePath(Application.EXEName);
end;

This would return 'D:\' if your program were running from the root directory of your cd. You can then add to this path if your text file is in another directory on the cd.

As for locating notepad, its given that it will always reside in the windows folder but you could perform a search for notepad.exe using the FindFirst and searchrec procedures, both of which are detailed in the Delphi helpfiles.
 Posted 18 years ago
Comment Quote
About Angel -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6504 (Level 1.2)  Reply to 6497
Reply Posted 6/5/2002 8:48:00 AM
Location=England  
Joined=19 years ago   MB Posts=199  
Matt Verratti
 (Inactive)
Libertyville, IL
Thanks. This works great. It leads me to a related question.....

What if this program is running off a CD? The notepad application exists on the users harddrive, but the text file is on the CD. is there a way to put the path of the file without the reference to the letter of the CD drive? Or is there a way to query the computer for the letter of the CD drive?

And I don't want to puch my luck, but can I call notepad without using an explicit path? Is there a way to tell the program to find the default viewer for txt files and use that to open the file?
 Posted 18 years ago (Thread Starter)
Comment Quote
About Matt Verratti -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6502 (Level 1.3)  Reply to 6497
Reply Posted 6/5/2002 8:37:00 AM
Location=Libertyville, IL  
Joined=18 years ago   MB Posts=12  
Most Recent Post
Matt Verratti
 (Inactive)
Libertyville, IL
Thanks Angel! You have helped me more in 10 minutes than anyone else I have communicated with during the past 7 days.
 Posted 18 years ago (Thread Starter)
Comment Quote
About Matt Verratti -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6511 (Level 1.4)  Reply to 6497
Reply Posted 6/5/2002 9:09:00 AM
Location=Libertyville, IL  
Joined=18 years ago   MB Posts=12  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1302A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #6497 Counter
1716
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech