Shellexecute Function (ZT)

xiaoxiao2021-03-06  56

Shellexecute Function

Performs an Operation on a specified file.

Syntax

Hinstance shellexecute (hwnd hwnd,

LPCTSTR LPOPERATION,

LPCTSTR LPFILE,

LPCTSTR LPPARETERS,

LPCTSTR LPDIRECTORY,

Int nshowcmd

);

Parameters

HWnd

.

LPOPERATION

[in] Pointer to a null-terminated string, referred to in this case as a

verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. For more information about verbs and their availability, see

Object Verbs. See

Extending Shortcut Menus for Further Discussion Of Shortcut Menus. The Following Verbs Are Commonly Used.

edit

Launches An Editor and Opens The Document for Editing. IF

LPFILE IS NOT A Document File, The Function Will Fail.

Explore

Explores the folder specified by

Lpfile.

Find

INITIATES A Search Starting from The Specified Directory.

Open

Opens the file specified by the file specified by the File Specified by

LPFile Parameter. The File Can Be An Executable File, A Document File, OR A Folder.

Print

PRINTS The Document File Specified by

LPFILE. IF

LPFILE IS NOT A Document File, The Function Will Fail.

NULL

For systems prior to Microsoft Windows 2000, The Default Verb IS Used IT IS Valid and Available In The Registry. If NOT, The "Open" VERB IS USED.

For Windows 2000 and Later Systems, The Default Verb IS Used if Available. If NOT, The "Open" Verb IS Used. If Neither Verb is Available, The System Uses The First Verb listed in The Registry.

lpfile

[In] Pointer to a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported on all objects. For EXAMPLE, NOT All Document Types Support The "Print" Verb.lpparameters

[in] IF the

LPFile Parameter Specifies An Executable File,

LPParameters Is a Pointer to a null-terminated string That specifies the application. The form of this string is to be invoked by the verb That is to be invoked.

LPFile Specifies a document file,

LPParameters Should Be Null.

LPDIRECTORY

Pointer to a null-terminated string That Specifier The Default Directory.

Nshowcmd

[in] Flags That Specify How an Application Is To Be Displayed When IT IS Opened. IF

LPFILE SPECIFIES A Document File, The Flag IS Simply Passed To The Associated Application. It is up to the application to decide how to handle.

SW_HIDE

HIDES The Window and Activates Another Window.

SW_MAXIMIZE

Maximizes the specified window.

SW_MINIMIZE

MINIMIZES The NEXT TOP-Level Window In The next top-level.

SW_RESTORE

Activates and displays the window. If The window is minimized or maximized, Windows Restores It to it ortholiginal size and position. An Application Should Specify This flagens.

SW_SHOW

Activates the window and displays it in its current size and position.

SW_SHOWDEFAULT

Sets the show state based on the sw_ flag specified in the sw_

Startupinfo Structure Passed to the

CreateProcess Function by The Program That Started The Application.An Application Should Call

Showwindow with this flag to set the initial show state of its main window.sw_showmaximized

Activates the window and displays it as a maximized window.

SW_SHOWMINIMIZED

Activates the window and displays it as a minimized window.

SW_SHOWMINNOACTIVE

Displays the window as a minimized window. The Active Window Remains Active.

SW_SHOWNA

Displays the window in its current state. The Active Window Remains Active.

SW_SHOWNOACTIVATE

Displays a window in its most the agent size and position. The Active Window Remains Active.

SW_SHOWNORMAL

Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

Return Value

Returns a value greater than 32 if successful, or an error value to 32 otherwise that is less than or equal. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It IS Not a true hinstance, however. The only thing That Can Be Done with the returned hinstance is to cast it to an int AND company it with the value.

0The operating system is out of memory or resources.ERROR_FILE_NOT_FOUNDThe specified file was not found.ERROR_PATH_NOT_FOUNDThe specified path was not found.ERROR_BAD_FORMATThe .exe file is invalid (non-Microsoft Win32 .exe or error in .exe image) .SE_ERR_ACCESSDENIEDThe operating system denied access to the specified file.SE_ERR_ASSOCINCOMPLETEThe file name association is incomplete or invalid.SE_ERR_DDEBUSYThe Dynamic Data Exchange (DDE) transaction could not be completed because other DDE transactions were being processed.SE_ERR_DDEFAILThe DDE transaction failed.SE_ERR_DDETIMEOUTThe DDE transaction could not be completed because the request timed out.SE_ERR_DLLNOTFOUNDThe specified dynamic-link library (DLL) was not found.SE_ERR_FNFThe specified file was not found.SE_ERR_NOASSOCThere is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not Printable.se_err_oomthere Was Not Enough Memory To Complete T He Operation.SE_ERR_PNFTHE Specified Path Was Not Found.se_err_sharea Sharing Violation Occurred.Remarks

This Method Allows You to Execute Any Commands in a Folder's Shortcut Menu or Stored in The Registry.

To Open a Folder, Use Either of the Following Calls:

Shellexecute (Handle, Null, , null, null, sw_shownormal);

oral

Shellexecute (Handle, "Open", , null, null, sw_shownormal);

To Explore A Folder, Use:

Shellexecute (Handle, "Explore", , null, null, sw_shownormal;

To Launch The Shell's Find Utility for A Directory, USE:

ShellExecute (handle, "find", , NULL, NULL, 0);. If lpOperation is NULL, the function opens the file specified by lpFile If lpOperation is "open" or "explore", the function attempts to open or Explore the folder.

To Obtain Information About The Application That Is Launched As A Result of Calling Shellexecute, Use ShellexecuteEx.

Note the

Launch Folder Windows in a Separate Process Setting in Folder Options Affects

Shellexecute. If That Option is disabled (The Default Setting),

SHELLEXECUTE Uses An Open Explorer WINDOW Rather Than Launch A New One. If No Explorer Window Is Open,

Shellexecute launches a new one.

Windows 95/98 / Me: ShellExecute is supported by the Microsoft Layer for Unicode To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98 / Me Systems..

Function Information

Minimum DLL Versionshell32.dll version 3.51 or laterCustom ImplementationNoHeadershellapi.hImport libraryshell32.libMinimum operating systemsWindows NT 3.1, Windows 95UnicodeImplemented as ANSI and Unicode versions.

See Also

Ishellexecutehook

转载请注明原文地址:https://www.9cbs.com/read-118156.html

New Post(0)