User Account Control UAC will prompt the user for consent to run the application elevated or enter the credentials of an administrator account used to run the application. Each verb corresponds to the command that would be used to launch the application from a console window. The open verb is a good example, as it is commonly supported. However, it is more commonly used to launch an application that operates on a particular file. For instance,.
|Published (Last):||25 March 2010|
|PDF File Size:||9.82 Mb|
|ePub File Size:||16.11 Mb|
|Price:||Free* [*Free Regsitration Required]|
Feel free to download and use any code or components, and to pass around copies of the articles but please do not remove our copyright notices or disclaimers. The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications.
Have you ever needed to run an external program from within your VFP application? Or pop up an email message window? Or play a sound file? Or open a file folder? Or launch the Find File dialogue? Or print an RTF document? You can perform all these tasks - and many more - by courtesy of a versatile API function called ShellExecute. The function has dozens of uses, and, if you have not yet made its acquaintance, we strongly recommend that you do so now.
What does it do? As you can see in the above code, ShellExecute takes six parameters. In VFP, you will usually set this to 0. Note that the parameter names shown here are for illustration only. But you must specify the data types. The most important parameters are the action and the filename. Make it generic Although the above code works fine on our system, it might not work on yours.
A more generic approach would be to specify, not the name of the Winzip program, but that of the zip file that you want to open. It will even work if the user has installed a different utility to process zip files - provided that the utility in question is associated with the ZIP file extension. Nor are you limited to opening the file.
ShellExecute can perform any action which is registered for the relevant document type. In the case of a DOC file, you could just as easily print the file. For more details of this technique, see the Foxstuff article, An easy way to send email from a Visual FoxPro application.
Of course, this assumes that Quikview. In that last example, the document name is passed as a command-line parameter, that is, as the fourth parameter to ShellExecute. Note that you have to provide the full path to the document, even if the file is in the VFP search path. Registered actions How do you know what actions are available for a given file or document?
One way to find out is to look in the Folder Options window. You get to this window from the Tools menu in Windows Explorer or in any folder window. Go to the File Types tab Figure 1 and scroll down until you see the file type that you are interested in. Select it, then click the Edit button this is labelled Advanced in some versions of Windows.
Figure 1: The File Types tab lists all the registered document types. Figure 2: Use this dialogue to view the registered actions. Another method is to look in the Registry. You could therefore programmatically search the Registry to determine the available actions the method of doing that is beyond the scope of this article.
Most file types have a default action, which is also specified in the Registry. If you omit the action parameter, the default action will be executed. Did it work? If ShellExecute succeeds, it returns an integer greater than The integer is in fact the handle of the main window of the application which has been launched. This could be useful if you want to use other API functions to manipulate the window in some way.
A returned value of 32 or lower indicates an error. The commonest error values are 2 invalid path or filename and 31 invalid action, or no application associated with the specified file. You might also come across a value of 8 insufficient memory and 11 invalid EXE file. By now, we hope you agree that ShellExecute opens up many interesting possibilities. We have used it dozens of times in our own applications, and we are sure that you will find it equally useful in yours.
Mike Lewis Consultants Ltd.
How to use the function ShellExecute in delphi 7?
Can I print documents from within my program, without explicitly starting the application that created the document, such as: print a Word-document without starting Word? How to open my browser with a local HTML page? How to surf to a site, i. And: how can I make my Delphi program wait until the external program is terminated? For just running an external application, or opening a registered file, opening a folder, printing a file, and so on
Execute and Run Applications and Files From Delphi Code
Feel free to download and use any code or components, and to pass around copies of the articles but please do not remove our copyright notices or disclaimers. The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly in your applications. Have you ever needed to run an external program from within your VFP application? Or pop up an email message window?
Delphi - ShellExecute
how would delphi open cmd