A brief description of the ShellExecute Function

Source: Internet
Author: User
The ShellExecute Function is always available in the process of writing code in Delphi, so we simply sort out its usage, because I failed to find a detailed explanation on Microsoft's website (of course, I checked the Chinese version. Why)

The meanings of the parameters and prototype of the ShellExecute Function are as follows:

Function ShellExecute (hwnd: hwnd; operation, filename, parameters, directory: pchar; showcmd: integer): hinst; stdcall;

● Hwnd: Specifies the parent window handle. When an error occurs during a function call, it is used as the parent window of the Windows message window. For example, you can set it to the application Main Window handle, that is, application. Handle, or desktop window handle (obtained using the getdesktopwindow function ).

● Operation: Specifies the operation to be performed.
The "open" operation indicates executing the program specified by the filename parameter or opening the file or folder specified by the filename parameter;
The "print" Operation prints the file specified by the filename parameter;
The "Browse e" operation indicates browsing the folder specified by the filename parameter.
If the parameter is set to nil, the default operation "open" is executed ";
Edit;
Find search
The last two are found on other websites and are not verified.

● Filename: used to specify the name of the file to be opened, the name of the program file to be executed, or the name of the folder to be browsed.

● Parameters: If the filename parameter is an executable program, this parameter specifies the command line parameter; otherwise, this parameter should be nil or pchar (0 ).

● Directory: used to specify the default directory.

● Showcmd: If the filename parameter is an executable program, this parameter specifies the initial display mode of the program window. Otherwise, this parameter should be set to 0.
This parameter can be one of the following values

Displaystate Value Description
Hide 0 Hide and activate other windows
Shownormal 1 Activate and display a window
If the window is minimized or maximized, restore it to its original size and position (same as the restore)
Showminimized 2 Activate and minimize windows
Showmaximized 3 Activate and maximize windows
Showminnoactivate 4 Display the window with the nearest size and position
Keep activity in the current activity window
Show 5 Activating the window and displaying its current size and position
Minimize 6 Minimizes the specified window and activates the top-level window in the system list
Showminnoactive 7 Display windows in minimal mode
Keep activity in the current activity window
Showna 8 Display the window in the latest status
Keep activity in the current activity window
Restore 9 Activation window and display
If the window is minimized or maximized, It is restored to its original size and position (same as shownormal)

Supplement:
Maximize: maximized window

If the ShellExecute Function is successfully called, the returned value is the instance handle of the executed program. If the returned value is less than 32, the response fails. the following response values are available:
2. Incorrect Association (for example, invalid URL)
29 Association failed
30. The associated application is busy...
31. No application is associated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.