术语 | shfileoperation |
释义 | SHFileOperation 语法: int SHFileOperation( LPSHFILEOPSTRUCT lpFileOp ); SHFileOperation函数 副本,移动,重命名或删除一个文件系统对象。此功能已被替换Windows Vista中的IFileOperation。 参数 lpFileOp [in]一个指向SHFILEOPSTRUCT结构,它包含此功能的信息需要进行指定的操作。此参数必须包含一个有效的值不为空。您有责任确认的价值。如果您不验证它,您会遇到意外的结果。 返回值 如果成功,返回0,否则非零。通常应简单的申请是否为零或非零。 这是一个好的做法,研究对SHFILEOPSTRUCT fAnyOperationsAborted成员的值。 SHFileOperation可以返回0成功,如果用户取消操作。如果您不检查fAnyOperationsAborted以及返回值,您可以不知道该函数完成了全部任务,您问它,您可能不正确的假设下进行。 不要使用此函数的返回值GetLastError函数。 要检查疑难解答的目的,为非零值,它们主要是映射到Winerror.h中定义的。然而,它的几个可能的返回值是根据前Win32错误代码,在某些情况下重叠,没有配合其含义后来Winerror.h中值。这些特定值的详细在这里,这些只有这些含义,应在Winerror.h中的代码接受特定的值。但是,这些值提供与这些警告: 这些都是前Win32错误代码,并不再支持或任何公共头文件中定义。要使用它们,您必须定义他们自己或进行比较的数值。 这些错误代码可能会有所变化,历来这样做。 这些值仅提供作为调试援助。他们不应该被视为权威。 错误CodeValueMeaning DE_SAMEFILE0x71The源和目标文件相同的文件。 DE_MANYSRC1DEST0x72Multiple文件路径,已列明在源缓冲区,但只有一个目标文件的路径。 DE_DIFFDIR0x73Rename行动指明,但目的地路径是不同的目录。使用移动操作代替。 DE_ROOTDIR0x74The来源是一个根目录,它不能被移动或重命名。 DE_OPCANCELLED0x75The行动用户取消,或者直接取消,请相应的标志是供应给SHFileOperation。 DE_DESTSUBTREE0x76The目标是一个源子树。 DE_ACCESSDENIEDSRC0x78Security设置拒绝访问的来源。 DE_PATHTOODEEP0x79The源或目标路径超过或将超过MAX_PATH。 DE_MANYDEST0x7AThe行动涉及多个目标路径,它可以在不移动操作情况。 DE_INVALIDFILES0x7CThe路径源或目标或双方是无效的。 DE_DESTSAMETREE0x7DThe源和目标具有相同的父文件夹。 DE_FLDDESTISFILE0x7EThe目标路径是现有文件。 DE_FILEDESTISFLD0x80The目标路径是现有文件夹。 DE_FILENAMETOOLONG0x81The文件名超过MAX_PATH。 DE_DEST_IS_CDROM0x82The目标是一个只读的CD - ROM,可能未格式化。 DE_DEST_IS_DVD0x83The目标是一个只读影碟,可能未格式化。 DE_DEST_IS_CDRECORD0x84The目标是一个可写的CD - ROM,可能未格式化。 DE_FILE_TOO_LARGE0x85The文件操作中涉及太大的目标媒体或文件系统。 DE_SRC_IS_CDROM0x86The源是只读的CD - ROM,可能未格式化。 DE_SRC_IS_DVD0x87The源是只读影碟,可能未格式化。 DE_SRC_IS_CDRECORD0x88The源是一个可写的CD - ROM,可能未格式化。 DE_ERROR_MAX0xB7MAX_PATH超出行动中。 0x402An未知的错误。这通常是由于源或目标无效的路径。此错误不会发生在Windows Vista和更高版本。 ERRORONDEST0x10000An未指定的错误发生在目标。 DE_ROOTDIR | ERRORONDEST0x10074Destination是根目录,不能更名。 备注 您应该使用完全具有这种功能限定路径名。使用相对路径名是不是线程安全的。 但有两个例外,您不能使用SHFileOperation摆脱本地驱动器的特殊文件夹通过指定的网络路径到远程计算机。例外的是我的文档(CSIDL_PERSONAL,CSIDL_DOCUMENTS)和我的图片文件夹(CSIDL_MYPICTURES)。 当用于删除一个文件,SHFileOperation永久删除的文件,除非您设置的SHFILEOPSTRUCT结构fFlags成员FOF_ALLOWUNDO标志指向lpFileOp。设置标志的文件发送到回收站。如果您想简单地删除文件,并保证它不是在回收站,使用的DeleteFile上。 如果复制回调处理程序是揭露和登记,SHFileOperation调用它,除非您设置的结构fFlags成员的国旗,如FOF_NOCONFIRMATION指向lpFileOp。见ICopyHook::为落实本回调处理细节CopyCallback。 文件删除是递归的,除非您设置lpFileOp的FOF_NORECURSION标志。 连接文件 使用Microsoft Windows 2000或更高版本,可以连接一个具有包含有关,例如图形交换格式(GIF)图像或样式表文件的文件夹的HTML文件。如果文件连接启用,当您移动或复制的HTML文件,连接文件夹及其所有文件也移动或复制。相反,如果移动与相关的文件夹,该HTML文件,也感动。 HTML文件必须具有。htm或。html的扩展名。您创建连接到相关的文件放置的文件夹将包含的HTML文件相同的文件夹中。该文件夹包含连接的文件的名称必须与HTML的名称由“_files后文件”或“相同。文件”(这是区分大小写,例如,“。文件”不工作)。一个例子就是为20元。 创建一个名为在C Test.htm一个文件:\\文件目录(C:\\文件\\ Test.htm)。 创建一个新文件夹名为Test.files在C:\\文件目录(C:\\文件\\ Test.files)。 填充几个文件夹。在此文件夹中任何文件连接到Test.htm。 移动或复制Test.htm文件保存到C:\\ Files2目录。 请注意,Test.files目录现在发现在C:\\ Files2目录中。 文件中的连接是默认启用的。它可以被禁用的添加REG_DWORD项,NoFileFolderConnection,如下所示: HKEY_CURRENT_USER 软件 微软 视窗 CurrentVersion 浏览器 NoFileFolderConnection 设置NoFileFolderConnection 1禁用文件连接。如果该值设置为零或丢失,文件连接启用。 只移动指定的文件及有关文件都不,设置在结构fFlags成员FOF_NO_CONNECTED_ELEMENTS标志指向lpFileOp。 请注意,文件夹的名称类似“MyFile_files使用”来定义一个连接可能不被用于Microsoft Windows NT的本地化版本有效。术语“文件”,可能需要由当地的语言等同语取代。 在Windows 95/98/Me:SHFileOperation是支持的Unicode(MSLU)微软层。要使用此,您必须将某些文件到您的应用,概述了对Unicode的Microsoft层在Windows 95/98系统。 功能信息 最低DLL版本 shell32.dll 4.0或更高版本 自定义ImplementationNo Headershellapi.h import libraryshell32.lib 最低经营systemsWindows NT 4.0中,Windows 95中 UnicodeImplemented为ANSI和Unicode版本。 ==英文原文==SHFileOperation Function Copies, moves, renames, or deletes a file system object. This function has been replaced in Windows Vista by IFileOperation . Syntax int SHFileOperation( LPSHFILEOPSTRUCT lpFileOp ); Parameters lpFileOp [in] A pointer to an SHFILEOPSTRUCT structure that contains information this function needs to carry out the specified operation. This parameter must contain a valid value that is not NULL. You are responsible for validating the value. If you do not validate it, you will experience unexpected results. Return Value Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. It is good practice to examine the value of the fAnyOperationsAborted member of the SHFILEOPSTRUCT. SHFileOperation can return 0 for success if the user cancels the operation. If you do not check fAnyOperationsAborted as well as the return value, you cannot know that the function accomplished the full task you asked of it and you might proceed under incorrect assumptions. Do not use GetLastError with the return values of this function. To examine the nonzero values for troubleshooting purposes, they largely map to those defined in Winerror.h. However, several of its possible return values are based on pre-Win32 error codes, which in some cases overlap the later Winerror.h values without matching their meaning. Those particular values are detailed here, and for these specific values only these meanings should be accepted over the Winerror.h codes. However, these values are provided with these warnings: These are pre-Win32 error codes and are no longer supported or defined in any public header file. To use them, you must either define them yourself or compare against the numerical value. These error codes are subject to change and have historically done so. These values are provided only as an aid in debugging. They should not be regarded as definitive. Error CodeValueMeaning DE_SAMEFILE0x71The source and destination files are the same file. DE_MANYSRC1DEST0x72Multiple file paths were specified in the source buffer, but only one destination file path. DE_DIFFDIR0x73Rename operation was specified but the destination path is a different directory. Use the move operation instead. DE_ROOTDIR0x74The source is a root directory, which cannot be moved or renamed. DE_OPCANCELLED0x75The operation was cancelled by the user, or silently cancelled if the appropriate flags were supplied to SHFileOperation. DE_DESTSUBTREE0x76The destination is a subtree of the source. DE_ACCESSDENIEDSRC0x78Security settings denied access to the source. DE_PATHTOODEEP0x79The source or destination path exceeded or would exceed MAX_PATH. DE_MANYDEST0x7AThe operation involved multiple destination paths, which can fail in the case of a move operation. DE_INVALIDFILES0x7CThe path in the source or destination or both was invalid. DE_DESTSAMETREE0x7DThe source and destination have the same parent folder. DE_FLDDESTISFILE0x7EThe destination path is an existing file. DE_FILEDESTISFLD0x80The destination path is an existing folder. DE_FILENAMETOOLONG0x81The name of the file exceeds MAX_PATH. DE_DEST_IS_CDROM0x82The destination is a read-only CD-ROM, possibly unformatted. DE_DEST_IS_DVD0x83The destination is a read-only DVD, possibly unformatted. DE_DEST_IS_CDRECORD0x84The destination is a writable CD-ROM, possibly unformatted. DE_FILE_TOO_LARGE0x85The file involved in the operation is too large for the destination media or file system. DE_SRC_IS_CDROM0x86The source is a read-only CD-ROM, possibly unformatted. DE_SRC_IS_DVD0x87The source is a read-only DVD, possibly unformatted. DE_SRC_IS_CDRECORD0x88The source is a writable CD-ROM, possibly unformatted. DE_ERROR_MAX0xB7MAX_PATH was exceeded during the operation. 0x402An unknown error occurred. This is typically due to an invalid path in the source or destination. This error does not occur on Windows Vista and later. ERRORONDEST0x10000An unspecified error occurred on the destination. DE_ROOTDIR | ERRORONDEST0x10074Destination is a root directory and cannot be renamed. Remarks You should use fully-qualified path names with this function. Using it with relative path names is not thread safe. With two exceptions, you cannot use SHFileOperation to move special folders from a local drive to a remote computer by specifying a network path. The exceptions are the My Documents ( CSIDL_PERSONAL , CSIDL_DOCUMENTS) and My Pictures folders ( CSIDL_MYPICTURES ). When used to delete a file, SHFileOperation permanently deletes the file unless you set the FOF_ALLOWUNDO flag in the fFlags member of the SHFILEOPSTRUCT structure pointed to by lpFileOp. Setting that flag sends the file to the Recycle Bin. If you want to simply delete a file and guarantee that it is not placed in the Recycle Bin, use DeleteFile . If a copy callback handler is exposed and registered, SHFileOperation calls it unless you set a flag such as FOF_NOCONFIRMATION in the fFlags member of the structure pointed to by lpFileOp. See ICopyHook::CopyCallback for details on implementing copy callback handlers. File deletion is recursive unless you set the FOF_NORECURSION flag in lpFileOp. Connecting Files With Microsoft Windows 2000 or later, it is possible to connect an HTML file with a folder that contains related files such as Graphics Interchange Format (GIF) images or style sheets. If file connection is enabled, when you move or copy the HTML file, the connected folder and all of its files are also moved or copied. Conversely, if you move the folder with the related files, the HTML file is also moved. The HTML file must have a .htm or .html extension. You create the connection to the related files by placing the folder that contains them into the same folder as the HTML file. The name of the folder that contains the connected files must be the same as the name of the HTML file followed by "_files" or ".files" (this is case sensitive; for example, ".Files" does not work). An example is given here. Create a file named Test.htm in the C:\\Files directory (C:\\Files\\Test.htm). Create a new folder named Test.files in the C:\\Files directory (C:\\Files\\Test.files). Populate the folder with a few files. Any file placed in this folder is connected to Test.htm. Move or copy the Test.htm file to the C:\\Files2 directory. Note that the Test.files directory is now found in the C:\\Files2 directory as well. File connection is enabled by default. It can be disabled by adding a REG_DWORD entry, NoFileFolderConnection, as shown here: HKEY_CURRENT_USER Software Microsoft Windows CurrentVersion Explorer NoFileFolderConnection Setting NoFileFolderConnection to 1 disables file connection. If the value is set to zero or is missing, file connection is enabled. To move only the specified files and none of the connected files, set the FOF_NO_CONNECTED_ELEMENTS flag in the fFlags member of the structure pointed to by lpFileOp. Note that the use of a folder with a name like "MyFile_files" to define a connection may not be valid for localized versions of Microsoft Windows NT. The term "files" may need to be replaced by the equivalent word in the local language. Windows 95/98/Me: SHFileOperation is supported by the Microsoft Layer for Unicode (MSLU). To use this, 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 4.0 or later Custom ImplementationNo Headershellapi.h Import libraryshell32.lib Minimum operating systemsWindows NT 4.0, Windows 95 UnicodeImplemented as ANSI and Unicode versions. ==原始网址==http://msdn.microsoft.com/en-us/library/bb762164(VS.85).aspx\n |
随便看 |
|
windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。