How many times have you wanted to execute some program from your Delphi application? Let's say we have a database application that uses some external backup utility. The back up utility takes parameters from your application, archives data, while your program waits until backup finishes. On the other hand, have you ever needed to open documents presented in a file listbox, just by double clicking on them, without opening the associated program first? Finally, imagine a link-labelin your program that will take the user to your home page (by executing the Internet Explorer). Moreover, what do you say about sending an e-mail directly from your Delphi application through default Windows e-mail client program (like MS Outlook Express). ShellExecuteTo launch an application or execute a file in Win32 environment we will use the ShellExecute Windows API function. Check out the help on ShellExecute for full description of parameters and error codes returned. As you will see we can open any type of document from our program without knowing which program is associated with it (this link is defined in the Windows Registry). Let's see some shell action! Be sure to add ShellApito your Unit's uses clause. Run Notepad
Open SomeText.txt with Notepad
Display the contents of the "DelphiDownload" folder
Execute a file according to its extension.
Here's how to Find an application associated with an extension Open web site or a *.htm file with the default web explorer
Here's how to Open a Web Browser in a new window Send an e-mail with the subject and the message body
Here's how to send an email with the attachment Execute a program and wait until it has finished. The following example uses the ShellExecuteEx API function.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论