ShellExecuteEx

This function performs an action on a file. The file can be an executable file or a document.

At a Glance

Header file: Shellapi.h
Versions: 1.0 and later

Syntax

WINSHELLAPI BOOL WINAPI ShellExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);

Parameters

lpExecInfo

Long pointer to a SHELLEXECUTEINFO structure that contains and receives information about the application being executed.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

If the function succeeds, it sets the hInstApp member of the SHELLEXECUTEINFO structure to the instance handle to the application that the function started. If the function fails, hInstApp is one of the SE_ERR_ error values indicating the cause of the failure. (An instance handle will always be greater than 32 and an error value less than 32.) Note that the SE_ERR_ error values are for compatibility with the ShellExecute function; use the GetLastError function to retrieve error information.

The error value returned by GetLastError corresponds to the SE_ERR_ values and is one of the values described in the following table.

Value Description
ERROR_FILE_NOT_FOUND The specified file was not found.
ERROR_PATH_NOT_FOUND The specified path was not found.
ERROR_DDE_FAIL The DDE transaction failed.
ERROR_NO_ASSOCIATION There is no application associated with the given file name extension.
ERROR_ACCESS_DENIED Access to the specified file is denied.
ERROR_DLL_NOT_FOUND One of the library files necessary to run the application can’t be found.
ERROR_CANCELLED The function prompted the user for the location of the application, but the user canceled the request.
ERROR_NOT_ENOUGH_MEMORY There is not enough memory to perform the specified action.
ERROR_SHARING_VIOLATION A sharing violation occurred.

See Also

SHELLEXECUTEINFO