Launch files and programs from your code using Delphi. ShellExecute(Handle, ‘open’,”,nil,nil, SW_SHOWNORMAL);. If that option is disabled (the default setting), ShellExecute uses an open Explorer window rather than launch a new one. If no Explorer window. The open verb is a good example, as it is commonly supported. When you use ShellExecute or ShellExecuteEx to open file.

Author: Mikale Groshura
Country: New Zealand
Language: English (Spanish)
Genre: Music
Published (Last): 5 March 2016
Pages: 246
PDF File Size: 20.70 Mb
ePub File Size: 15.40 Mb
ISBN: 245-2-27082-446-9
Downloads: 29936
Price: Free* [*Free Regsitration Required]
Uploader: Meztigal

If the window is minimized or maximized, Windows restores it to its original size and position. For just running an external application, or opening a registered file, opening a folder, printing a file, and so on For this Excel or later should have installed in our system.

In that case, COM should be initialized as shown here: EX – PChar filename. ShellExecute Sends Email using default depphi client software installed on user’s system. ShellExecute in Delphi — Launch external applications. What happens next, depends from the state of the “Wait for termination” checkbox:. This error will sshellexecute be returned if you attempt to shellexedute a file that is not printable. Launching an external program and waiting until it is terminated is quite another story The active window remains active.


A pointer to a null -terminated string, referred to in this case as a verbthat specifies the action to be performed. The application first retrieves the PIDL of the Windows directory, and enumerates its contents until it finds the first.

Running external applications: ShellExecute and ShellExecuteEx

So Delphi provides so many easiest ways to send mail from our Delphi application. Note the added extra touch: GetDisplayNameOf is used to retrieve the file’s parsing name instead of its display name. I have a form in a Delphi project. LPCTSTR If lpFile specifies an executable file, this parameter is a pointer to a null -terminated string delphhi specifies the parameters to be passed to the application. In Delphi we don’t required any third party components to send mails.

This method allows you to execute any commands in a folder’s shortcut menu or stored in the registry. ZIPthe fully commented source code files for this project.

Have a look in our download section, under “Mini Tutorial Projects”.

ShellExecute in Delphi

How to surf to a site, i. Upon completion of the external application, the demo form is restored in its original state.

To provide the site to ShellExecuteEx:. If lpFile is not a document file, the function will fail.


I wrapped it all up in a ready-to-go demo project see picture abovewhich demonstrates the use of the functions discussed above. The following sample console application illustrates the use of ShellExecuteEx.

It can be cast only to an int and compared to either 32 or the following error codes below. How to open windows explorer when I click a button? These values are defined in Winuser.

As mentioned ShellAPI must be added to your uses list. Finally, if an error occurs, such as specifying to run a non-existent program, or print a file that doesn’t exist shellexecite your system, then an appropriate error message will show up. To specify a Shell namespace object, pass the fully qualified parse name. To make it easier to see what is happening, we made the window of the demo stay on top of all other windows. The handle is more about Windows managing the active window and window ownership I think.

If that option is disabled the default settingShellExecute uses an open Explorer window rather than launch a new one.