网站首页  词典首页

请输入您要查询的函数:

 

术语 reopenfile
释义 ReOpenFile
语法:
C++
HANDLE WINAPI ReOpenFile(
__in HANDLE hOriginalFile,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in DWORD dwFlags
);
ReOpenFile功能
重新开放使用不同的访问权限指定的文件系统对象,共享模式,和标志。
参数
hOriginalFile [in]
句柄的对象重新开放。该对象必须已经建立了CreateFile函数。
dwDesiredAccess [in]
所需要的访问对象。对于一个值列表,请参阅文件安全性和访问权限。您不能要求一个接入模式,与以前公开要求其办理指定的共享模式的冲突仍处于打开状态。
如果这个参数是零(0),应用程序可以查询,而不访问设备的设备属性。这是有用的,如果应用程序想确定一个软盘驱动器的大小和格式,它无需在软盘驱动器支持。
dwShareMode [in]
对象的共享模式。您不能要求共享模式,与以前的公开要求的处理规定的访问模式的冲突仍处于打开状态。
如果这个参数是零(0)和成功CreateFile,对象不能共享,不能打开,直至再次关闭处理。
为了使其他进程共享的对象,而您的进程已经打开,使用一个或多个下列值的组合来指定访问时,他们可以要求他们打开的对象类型。这些共享选项保持有效,直到关闭句柄的对象。
ValueMeaning
FILE_SHARE_DELETE
0x00000004Enables随后在对象上打开操作要求删除访问。否则,其他进程无法打开该对象,如果他们的要求删除访问。
如果对象已被删除访问打开的共享模式必须包括此标志。
FILE_SHARE_READ
0x00000001Enables随后在对象上打开操作要求读取访问。否则,其他进程无法打开该对象,如果他们的要求读访问。
如果对象已被读取权限打开,共享模式必须包括此标志。
FILE_SHARE_WRITE
0x00000002Enables随后在对象上打开操作要求写访问。否则,其他进程无法打开该对象,如果他们的要求写访问。
如果对象已经以写访问打开的共享模式必须包括此标志。
dwFlags [in]
该文件标志。此参数可以是一个或多个下列值。
ValueMeaning
FILE_FLAG_BACKUP_SEMANTICS
0x02000000Indicates该文件被打开或备份或还原操作创建。该系统保证了调用进程重写文件的安全检查,只要它有SE_BACKUP_NAME和SE_RESTORE_NAME特权。有关更多信息,请参阅更改权限的令牌。
您还可以设置此标志以获取句柄到一个目录。凡表示,一个目录句柄可以通过一个文件句柄地方的一些功能。
FILE_FLAG_DELETE_ON_CLOSE
0x04000000Indicates该操作系统后立即删除其句柄已经关闭,而不是指定的处理,而且其他任何公开或重复处理所有的文件。
随后打开该文件的请求失败,除非FILE_SHARE_DELETE使用。
FILE_FLAG_NO_BUFFERING
0x20000000Instructs公开制度,没有中间缓冲或缓存文件。当与FILE_FLAG_OVERLAPPED相结合,最大的国旗给异步的性能,因为I / O并不依赖于内存管理器的同步操作。然而,一些I / O操作需要较长时间,因为数据不被缓存中举行。
应用程序时,必须符合与FILE_FLAG_NO_BUFFERING开启的档案工作的具体要求:
文件访问必须开始字节偏移在文件中属于体积部门规模的整数倍。
文件的访问,必须为字节的数量部门规模的整数倍号码。例如如果界的大小为512字节,应用程序可以请求读取和512,1024,1536,或2048个字节写,而不是335,981或7171字节。
缓冲区地址的读写操作,应部门对齐(在内存地址数量部门规模的整数倍数对齐)。根据不同的磁盘上,这一要求可能无法执行。
一个方法对齐卷的扇区大小的整数倍缓冲区是使用VirtualAlloc分配的缓冲区。它分配内存的地址是操作系统内存页大小的整数倍一致。由于这两个内存页和数量扇区大小为2的权力,这记忆也对齐地址是卷的扇区大小的整数倍。内存页4-8大小kb;部门是512字节(硬盘)或2048字节(CD)的,因此,体积部门不能比的内存页大。
应用程序可以通过调用确定GetDiskFreeSpace函数卷部门的规模。
FILE_FLAG_OPEN_NO_RECALL
0x00100000Indicates该文件数据请求,但它应该继续驻留在远程存储。它不应该运回本地存储。这个标志是专供远程存储系统的使用。
FILE_FLAG_OPEN_REPARSE_POINT
0x00200000When此标志使用,正常的分析点的处理不会发生,并ReOpenFile试图打开重分析点。当一个文件被打开,文件句柄返回,是否过滤器,控制分析点已开始运作。这个标志不能用于与CREATE_ALWAYS标志。如果该文件不是一个分析点,那么这个标志被忽略。
FILE_FLAG_OVERLAPPED
0x40000000Instructs系统初始化对象,以便操作,采取大量时间来处理返回ERROR_IO_PENDING。当操作完成后,指定的事件设置为信号状态。
当您指定FILE_FLAG_OVERLAPPED,文件读写功能,必须指定一个OVERLAPPED结构。也就是说,当FILE_FLAG_OVERLAPPED被指定,应用程序必须执行重叠的阅读和写作。
当FILE_FLAG_OVERLAPPED被指定,系统不会保持文件指针。该文件的位置必须通过作为lpOverlapped参数部分(指向一个OVERLAPPED结构)的文件中读取和书写功能。
该标志也使多个要执行的操作与处理(一同步读写操作,同时,例如)。
FILE_FLAG_POSIX_SEMANTICS
0x0100000Indicates该文件是要按照POSIX的访问规则。这包括允许多个文件的名称,只在不同的情况下,对文件系统支持这种命名。使用时请务必小心,因为文件与此标志创建的选项可能无法访问所编写的应用程序为MS - DOS或16位Windows。
FILE_FLAG_RANDOM_ACCESS
0x10000000Indicates该文件是随机访问。该系统可以使用提示此文件缓存优化。
FILE_FLAG_SEQUENTIAL_SCAN
0x08000000Indicates该文件被访问从开始到结束顺序。该系统可以使用提示此文件缓存优化。如果应用程序移动的随机存取文件指针,优化缓存可能不会出现,但仍然是正确的操作保证。
指定这个标志可以提高应用软件的性能阅读使用顺序访问大型文件。性能收益可以更加明显的应用主要是大文件的读取顺序,但偶尔跳过小范围的字节。
FILE_FLAG_WRITE_THROUGH全方位
0x80000000Instructs系统写入任何中间缓存并直接转到磁盘。该系统仍然可以缓存写入操作,但不能延迟刷新。
如果句柄代表了一个命名管道客户端,dwFlags参数也可以包含的信息安全服务质量。有关更多信息,请参阅模拟Level。当调用应用程序指定SECURITY_SQOS_PRESENT标志,dwFlags参数可以包含一个或多个下列值。
ValueMeaning
SECURITY_ANONYMOUSImpersonate客户端的匿名模拟级别。
SECURITY_CONTEXT_TRACKINGThe安全跟踪方式是动态的。如果此标志没有被指定,安全跟踪方式是静态的。
SECURITY_DELEGATIONImpersonate客户端在模拟级别的代表团。
SECURITY_EFFECTIVE_ONLYOnly启用的客户端的安全性方面问题的可用服务器。如果您不指定此标志,客户端的安全上下文中的所有方面都可用。
这允许客户端限制和特权的群体,一个服务器可以同时使用模拟客户端。
SECURITY_IDENTIFICATIONImpersonate客户身份查验模拟级别。
SECURITY_IMPERSONATIONImpersonate客户在模拟模拟级别。
返回值
如果函数成功,返回值是一个开放的句柄指定的文件。
如果函数失败,返回值是INVALID_HANDLE_VALUE。为了获得更多错误信息,调用GetLastError。
备注
dwFlags参数不能包含文件的属性标志(FILE_ATTRIBUTE_ *)的。这些只能在指定的文件时创建的。
要编译的应用程序使用此函数,定义为0x0502或更高_WIN32_WINNT宏。有关详细信息,请参阅使用Windows头。
要求:
client最低支持Vista
最低支持serverWindows服务器2003
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateFile
文件管理函数
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==ReOpenFile Function
Reopens the specified file system object with different access rights, sharing mode, and flags.
Syntax
C++
HANDLE WINAPI ReOpenFile(
__in HANDLE hOriginalFile,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in DWORD dwFlags
);
Parameters
hOriginalFile [in]
A handle to the object to be reopened. The object must have been created by the CreateFile function.
dwDesiredAccess [in]
The required access to the object. For a list of values, see File Security and Access Rights . You cannot request an access mode that conflicts with the sharing mode specified in a previous open request whose handle is still open.
If this parameter is zero (0), the application can query device attributes without accessing the device. This is useful if an application wants to determine the size of a floppy disk drive and the formats it supports without requiring a floppy in the drive.
dwShareMode [in]
The sharing mode of the object. You cannot request a sharing mode that conflicts with the access mode specified in a previous open request whose handle is still open.
If this parameter is zero (0) and CreateFile succeeds, the object cannot be shared and cannot be opened again until the handle is closed.
To enable other processes to share the object while your process has it open, use a combination of one or more of the following values to specify the type of access they can request when they open the object. These sharing options remain in effect until you close the handle to the object.
ValueMeaning
FILE_SHARE_DELETE
0x00000004Enables subsequent open operations on the object to request delete access. Otherwise, other processes cannot open the object if they request delete access.
If the object has already been opened with delete access, the sharing mode must include this flag.
FILE_SHARE_READ
0x00000001Enables subsequent open operations on the object to request read access. Otherwise, other processes cannot open the object if they request read access.
If the object has already been opened with read access, the sharing mode must include this flag.
FILE_SHARE_WRITE
0x00000002Enables subsequent open operations on the object to request write access. Otherwise, other processes cannot open the object if they request write access.
If the object has already been opened with write access, the sharing mode must include this flag.

dwFlags [in]
The file flags. This parameter can be one or more of the following values.
ValueMeaning
FILE_FLAG_BACKUP_SEMANTICS
0x02000000Indicates that the file is being opened or created for a backup or restore operation. The system ensures that the calling process overrides file security checks, provided it has the SE_BACKUP_NAME and SE_RESTORE_NAME privileges. For more information, see Changing Privileges in a Token .
You can also set this flag to obtain a handle to a directory. Where indicated, a directory handle can be passed to some functions in place of a file handle.
FILE_FLAG_DELETE_ON_CLOSE
0x04000000Indicates that the operating system is to delete the file immediately after all of its handles have been closed, not just the specified handle but also any other open or duplicated handles.
Subsequent open requests for the file fail, unless FILE_SHARE_DELETE is used.
FILE_FLAG_NO_BUFFERING
0x20000000Instructs the system to open the file with no intermediate buffering or caching. When combined with FILE_FLAG_OVERLAPPED, the flag gives maximum asynchronous performance, because the I/O does not rely on the synchronous operations of the memory manager. However, some I/O operations take longer, because data is not being held in the cache.
An application must meet specific requirements when working with files opened with FILE_FLAG_NO_BUFFERING:
File access must begin at byte offsets within the file that are integer multiples of the volume sector size.
File access must be for numbers of bytes that are integer multiples of the volume sector size. For example, if the sector size is 512 bytes, an application can request reads and writes of 512, 1024, 1536, or 2048 bytes, but not of 335, 981, or 7171 bytes.
Buffer addresses for read and write operations should be sector aligned (aligned on addresses in memory that are integer multiples of the volume sector size). Depending on the disk, this requirement may not be enforced.
One way to align buffers on integer multiples of the volume sector size is to use VirtualAlloc to allocate the buffers. It allocates memory that is aligned on addresses that are integer multiples of the operating system memory page size. Because both memory page and volume sector sizes are powers of 2, this memory is also aligned on addresses that are integer multiples of a volume sector size. Memory pages are 4-8 KB in size; sectors are 512 bytes (hard disks) or 2048 bytes (CD), and therefore, volume sectors can never be larger than memory pages.
An application can determine a volume sector size by calling the GetDiskFreeSpace function.
FILE_FLAG_OPEN_NO_RECALL
0x00100000Indicates that the file data is requested, but it should continue to reside in remote storage. It should not be transported back to local storage. This flag is intended for use by remote storage systems.
FILE_FLAG_OPEN_REPARSE_POINT
0x00200000When this flag is used, normal reparse point processing does not occur, and ReOpenFile attempts to open the reparse point. When a file is opened, a file handle is returned, whether or not the filter that controls the reparse point is operational. This flag cannot be used with the CREATE_ALWAYS flag. If the file is not a reparse point, then this flag is ignored.
FILE_FLAG_OVERLAPPED
0x40000000Instructs the system to initialize the object, so that operations that take a significant amount of time to process return ERROR_IO_PENDING. When the operation is finished, the specified event is set to the signaled state.
When you specify FILE_FLAG_OVERLAPPED, the file read and write functions must specify an OVERLAPPED structure. That is, when FILE_FLAG_OVERLAPPED is specified, an application must perform overlapped reading and writing.
When FILE_FLAG_OVERLAPPED is specified, the system does not maintain the file pointer. The file position must be passed as part of the lpOverlapped parameter (pointing to an OVERLAPPED structure) to the file read and write functions.
This flag also enables more than one operation to be performed simultaneously with the handle (a simultaneous read and write operation, for example).
FILE_FLAG_POSIX_SEMANTICS
0x0100000Indicates that the file is to be accessed according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support such naming. Use care when using this option because files created with this flag may not be accessible by applications written for MS-DOS or 16-bit Windows.
FILE_FLAG_RANDOM_ACCESS
0x10000000Indicates that the file is accessed randomly. The system can use this as a hint to optimize file caching.
FILE_FLAG_SEQUENTIAL_SCAN
0x08000000Indicates that the file is to be accessed sequentially from beginning to end. The system can use this as a hint to optimize file caching. If an application moves the file pointer for random access, optimum caching may not occur; however, correct operation is still guaranteed.
Specifying this flag can increase performance for applications that read large files using sequential access. Performance gains can be even more noticeable for applications that read large files mostly sequentially, but occasionally skip over small ranges of bytes.
FILE_FLAG_WRITE_THROUGH
0x80000000Instructs the system to write through any intermediate cache and go directly to disk. The system can still cache write operations, but cannot lazily flush them.

If the handle represents the client side of a named pipe, the dwFlags parameter can also contain Security Quality of Service information. For more information, see Impersonation Levels . When the calling application specifies the SECURITY_SQOS_PRESENT flag, the dwFlags parameter can contain one or more of the following values.
ValueMeaning
SECURITY_ANONYMOUSImpersonate the client at the Anonymous impersonation level.
SECURITY_CONTEXT_TRACKINGThe security tracking mode is dynamic. If this flag is not specified, the security tracking mode is static.
SECURITY_DELEGATIONImpersonate the client at the Delegation impersonation level.
SECURITY_EFFECTIVE_ONLYOnly the enabled aspects of the client security context are available to the server. If you do not specify this flag, all aspects of the client security context are available.
This allows the client to limit the groups and privileges that a server can use while impersonating the client.
SECURITY_IDENTIFICATIONImpersonate the client at the Identification impersonation level.
SECURITY_IMPERSONATIONImpersonate the client at the Impersonation impersonation level.

Return Value
If the function succeeds, the return value is an open handle to the specified file.
If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError .
Remarks
The dwFlags parameter cannot contain any of the file attribute flags (FILE_ATTRIBUTE_*). These can only be specified when the file is created.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0502 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2003
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateFile
File Management Functions
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365497(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 13:20:31