网站首页  词典首页

请输入您要查询的函数:

 

术语 shellexecute
释义 ShellExecute
语法:
HINSTANCE ShellExecute( HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
ShellExecute函数
执行一个指定的文件的操作。
参数
hwnd
[in]的句柄所有者窗口用于显示用户界面(UI)或错误消息使用。此值可以是NULL如果操作不相关的一个窗口。
lpOperation
[in]指向一个空结束的字符串,提到这个案件作为一个动词,它指定要执行的操作。可用动词设置取决于特定的文件或文件夹。一般来说,从一个对象操作的快捷菜单可用动词。下列常用动词:
编辑
推出一个编辑器,并打开编辑文件。如果lpFile不是一个文档文件,该函数将失败。
探索
探索由lpFile指定的文件夹。
查找
搜索开始启动一个由lpDirectory指定的目录。
打开
打开由lpFile参数指定的项目。该项目可以是一个文件或文件夹。
打印
打印文件指定lpFile。如果lpFile不是一个文档文件,该功能失败。

在微软之前的Windows 2000系统,默认的动词使用,如果它是有效的,并在注册表中可用。如果没有,“开放”的动词使用。
在Windows 2000及更高版本,默认动词则使用可用。如果没有,“开放”的动词使用。如果没有动词可用,系统将使用第一个动词在注册表中列出。
lpFile
[in]指向一个空结束的字符串指定的文件或对象上执行指定的动词。要指定壳牌公司命名对象,通过完全合格的解析名称。请注意,并非所有的动词,在各对象的支持。举例来说,并非所有文件类型支持的“打印”动词。如果一个相对路径是用于lpDirectory参数不使用相对路径为lpFile。
lpParameters
[in]如果lpFile指定一个可执行文件,该参数是对一个空指针结尾的字符串,指定要传递给应用程序参数。这个字符串的格式是由动词要被调用。如果lpFile指定一个文档文件,lpParameters应该为null。
lpDirectory
[in]指向一个空结束的字符串指定默认的(工作)的行动指南。如果此值为NULL,当前的工作目录使用。如果一个相对路径提供lpFile,不要使用相对路径为lpDirectory。
nShowCmd
[in]的标志指定应用程序如何时显示它打开。如果lpFile指定一个文档文件,该标志只是传递到关联的应用程序。它是由应用程序来决定如何处理它。
SW_HIDE
隐藏窗口并激活另一个窗口。
SW_MAXIMIZE
最大化指定的窗口。
SW_MINIMIZE
最小化指定的窗口和激活的z顺序下一个顶层窗口。
SW_RESTORE
激活并显示窗口。如果窗口是最小化或最大化,Windows可以恢复到了原来的大小和位置。应用程序应指定此标志时,还原最小化窗口。
SW_SHOW
激活窗口,并显示在当前的大小和位置。
SW_SHOWDEFAULT
设置显示,国有关于STARTUPINFO结构中指定的SW_旗的传递给CreateProcess函数的程序开始应用。应用程序应调用此标志ShowWindow确定其主窗口的初始显示状态。
SW_SHOWMAXIMIZED
激活窗口,并显示为最大化窗口。
SW_SHOWMINIMIZED
激活窗口,并显示为最小化窗口。
SW_SHOWMINNOACTIVE
窗口中显示最小化窗口。活动窗口保持活跃。
SW_SHOWNA
在当前状态显示窗口。活动窗口保持活跃。
SW_SHOWNOACTIVATE
显示在其最近的大小和位置窗口。活动窗口保持活跃。
SW_SHOWNORMAL
激活并显示一个窗口。如果窗口是最小化或最大化,Windows可以恢复到了原来的大小和位置。应用程序应指定此标志时,显示第一次窗口。
返回值
如果函数成功,它返回一个值大于32。如果函数失败,返回错误值,指示失败的原因。返回值是人作为一个向后兼容的16位Windows应用程序的hInstance。它不是一个真正的HINSTANCE,但是。它可以只转换为int和比较都有32或以下错误代码如下。
0The操作系统内存不足或资源。
ERROR_FILE_NOT_FOUNDThe指定的文件未找到。
ERROR_PATH_NOT_FOUNDThe指定的路径未找到。
ERROR_BAD_FORMATThe。exe文件是无效的(非的Microsoft Win32。exe或错误的。exe图像)。
SE_ERR_ACCESSDENIEDThe操作系统拒绝访问指定的文件。
SE_ERR_ASSOCINCOMPLETEThe会是文件名不完整或无效。
SE_ERR_DDEBUSYThe动态数据交换(DDE)的交易无法完成,因为其他DDE交易正在处理中。
SE_ERR_DDEFAILThe DDE事务失败。
SE_ERR_DDETIMEOUTThe DDE的交易无法完成,因为请求超时。
SE_ERR_DLLNOTFOUNDThe指定的DLL没有找到。
SE_ERR_FNFThe指定的文件未找到。
SE_ERR_NOASSOCThere是给定的文件扩展名相关联的应用程序。此错误也将返回如果您尝试打印一个文件,不打印。
SE_ERR_OOMThere没有足够的内存来完成该操作。
SE_ERR_PNFThe指定的路径未找到。
SE_ERR_SHAREA共享冲突发生。
备注
因为ShellExecute可以委托执行的Shell扩展(数据源,上下文菜单处理程序,实现动词)是被激活使用组件对象模型(COM)时,COM应被初始化之前ShellExecute被调用。有些Shell扩展需要的COM单线程单元(STA)的类型。在这种情况下,初始化的COM应该如下所示:
CoInitializeEx的(空,COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)有一定情况下不使用ShellExecute的外壳扩展这些类型之一,这种情况下,不需要的COM进行初始化的。然而,这是很好的做法始终initalize使用此功能前的COM。
此方法允许您执行一个文件夹中的快捷菜单上的任何命令或存储在注册表中。
打开文件夹,使用下面的调用使用:
ShellExecute(处理,空,,空,空,SW_SHOWNORMAL);

ShellExecute(处理,“开放”,,空,空,SW_SHOWNORMAL);
要探索一个文件夹,使用下面的调用:
ShellExecute(处理,“探讨”,,空,空,SW_SHOWNORMAL);
壳牌推出的查找目录工具,使用下面的调用。
ShellExecute(处理,“发现”,,空,空,0);
如果lpOperation为NULL,则函数打开由lpFile指定的文件。如果lpOperation是“打开”或“探索”,函数试图打开文件夹或探讨。
要获得有关这是作为一个调用ShellExecute,使用ShellExecuteEx结果启动的应用程序的信息。
注意:在一个单独的文件夹选项,在制定过程中打开文件夹窗口的影响ShellExecute。如果该选项被禁用(默认设置),ShellExecute使用了一个开放的资源管理器窗口,而不是推出一个新的。如果没有资源管理器窗口处于打开状态,ShellExecute推出一个新的。
在Windows 95/98/Me:ShellExecute是支持的Unicode(MSLU)微软层。要使用MSLU,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98系统。
功能信息
最低DLL版本 shell32.dll版本3.51或更高版本
自定义ImplementationNo
Headershellapi.h
import libraryshell32.lib
最低经营systemsWindows新台币3.1,Windows 95中
UnicodeImplemented为ANSI和Unicode版本。
参见
ShellExecuteEx,IShellExecuteHook,CoInitializeEx的
==英文原文==ShellExecute Function
Performs an operation on a specified file.
Syntax
HINSTANCE ShellExecute( HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
Parameters
hwnd
[in] A handle to the owner window used for displaying a user interface (UI) or error messages. This value can be NULL if the operation is not associated with a window.
lpOperation
[in] A 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. 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 a folder specified by lpFile.
find
Initiates a search beginning in the directory specified by lpDirectory.
open
Opens the item specified by the lpFile parameter. The item can be a file or folder.
print
Prints the file specified by lpFile. If lpFile is not a document file, the function fails.
NULL
In systems prior to Microsoft Windows 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.
In Windows 2000 and later, 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] A 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. If a relative path is used for the lpDirectory parameter do not use a relative path for lpFile.
lpParameters
[in] If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.
lpDirectory
[in] A pointer to a null-terminated string that specifies the default (working) directory for the action. If this value is NULL, the current working directory is used. If a relative path is provided at lpFile, do not use a relative path for lpDirectory.
nShowCmd
[in] The 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 it.
SW_HIDE
Hides the window and activates another window.
SW_MAXIMIZE
Maximizes the specified window.
SW_MINIMIZE
Minimizes the specified window and activates the next top-level window in the z-order.
SW_RESTORE
Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
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 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 recent 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
If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below.
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 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 the operation.
SE_ERR_PNFThe specified path was not found.
SE_ERR_SHAREA sharing violation occurred.
Remarks
Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, verb implementations) that are activated using Component Object Model (COM), COM should be initialized before ShellExecute is called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as shown here:
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)There are certainly instances where ShellExecute does not use one of these types of Shell extension and those instances would not require COM to be initialized at all. Nonetheless, it is good practice to always initalize COM before using this function.
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);
or
ShellExecute(handle, "open", , NULL, NULL, SW_SHOWNORMAL);
To explore a folder, use the following call:
ShellExecute(handle, "explore", , NULL, NULL, SW_SHOWNORMAL);
To launch the Shell's Find utility for a directory, use the following call.
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 (MSLU). To use MSLU, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows Me/98/95 Systems .
Function Information
Minimum DLL Versionshell32.dll version 3.51 or later
Custom ImplementationNo
Headershellapi.h
Import libraryshell32.lib
Minimum operating systemsWindows NT 3.1, Windows 95
UnicodeImplemented as ANSI and Unicode versions.
See Also
ShellExecuteEx , IShellExecuteHook , CoInitializeEx
==原始网址==http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:29:37