网站首页  词典首页

请输入您要查询的函数:

 

术语 openfilebyid
释义 OpenFileById
语法:
C++
HANDLE WINAPI OpenFileById(
__in HANDLE hFile,
__in LPFILE_ID_DESCRIPTOR lpFileID,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwFlags
);
OpenFileById功能
打开文件相匹配指定的标识符。
参数
hFile [in]
阿手柄上的任何卷或共享该文件被打开存储的文件。
lpFileID [in]
一个 FILE_ID_DESCRIPTOR标识要打开的文件指针。
dwDesiredAccess [in]
到对象访问。访问可以读,写,或两者兼而有之。
有关更多信息,请参阅文件安全性和访问权限。您不能要求一个访问模式相冲突的共享模式,是在一个开放的要求,有一个打开句柄指定。
如果这个参数是零(0),应用程序可以查询文件和设备属性而不必访问设备。这是非常有用的应用程序,以确定软盘驱动器的大小和格式,它无需在一个软盘驱动器支持。它也可以用来为一个文件或目录存在的情况下测试开放读或写访问。
dwShareMode [in]
对象的共享模式,可以读,写,都,或无。
您不能要求共享模式相冲突的访问模式是在一个开放的要求,有一个开放的处理,因为这将导致以下共享冲突:(ERROR_SHARING_VIOLATION)指定。有关更多信息,请参阅创建和打开文件。
如果这个参数是零(0)和OpenFileById成功,对象不能共享,不能打开,直至再次关闭处理。有关更多信息,请参阅本主题的备注部分。
共享选项保持有效,直到关闭对象句柄。
为使进程共享的对象,而另一个进程对象的开放,使用一个或多个下列值的组合来指定访问模式,可以要求打开对象。
ValueMeaning
FILE_SHARE_DELETE
0x00000004Enables对象上的后续行动,以开放的要求删除访问。
否则,其他进程无法打开该对象,如果他们的要求删除访问。
如果此标志没有被指定,但对象已经删除访问打开,该功能失败。
FILE_SHARE_READ
0x00000001Enables对象上的后续行动,要求开放读取权限。
否则,其他进程无法打开该对象,如果他们的要求读访问。
如果此标志没有被指定,但对象已经读访问打开,该功能失败。
FILE_SHARE_WRITE
0x00000002Enables对象上的后续行动,以开放的要求写访问。
否则,其他进程无法打开该对象,如果他们的要求写访问。
如果此标志没有被指定,但对象已开放了写入访问或与写访问文件映射,函数失败。
lpSecurityAttributes [中,可选]
保留。
dwFlags [in]
该文件标志。
当OpenFileById打开一个文件,它结合了现有的文件属性的文件旗帜,忽略任何提供文件属性。此参数可以包括下列任何标志的组合。
ValueMeaning
FILE_FLAG_BACKUP_SEMANTICS
0x02000000A文件正在被打开了备份或还原操作。该系统保证了调用进程覆盖文件时的安全检查过程SE_BACKUP_NAME和SE_RESTORE_NAME特权。有关更多信息,请参阅更改权限的令牌。
您必须设置此标志以获取句柄到一个目录。一个目录句柄可以被传递到某些职能而不是一个文件句柄。有关更多信息,请参阅目录把手。
FILE_FLAG_NO_BUFFERING
0x20000000The系统打开一个没有系统缓存文件。这个标志不影响硬盘缓存。当与FILE_FLAG_OVERLAPPED相结合,最大的国旗给异步的性能,因为I / O并不依赖于内存管理器的同步操作。然而,一些I / O操作需要更多的时间,因为数据不被缓存中举行。此外,文件元数据可能仍然被缓存。元数据刷新到磁盘,使用FlushFileBuffers函数。
应用程序时,必须符合与处理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
0x00100000The文件数据请求,但应继续在远程存储位置。它不应该运回本地存储。这个标志由远程存储系统的使用。
FILE_FLAG_OPEN_REPARSE_POINT
0x00200000When此标志使用,正常的分析点的处理不会发生,并OpenFileById试图打开重分析点。当一个文件被打开,文件句柄返回,是否过滤器,控制分析点已开始运作。这个标志不能用于与CREATE_ALWAYS标志。如果该文件不是一个分析点,那么这个标志被忽略。
FILE_FLAG_OVERLAPPED
0x40000000The文件被打开或创建的异步I / O的当操作完成后,该事件在指定OVERLAPPED结构调用设置为信号状态。操作,采取大量时间来处理返回ERROR_IO_PENDING。
如果这个标志被指定,该文件可用于同步读取和写入操作。该系统并没有文件指针,因此,您必须通过文件位置的读写重叠的机构的职能或更新的文件指针。
这标志,如果没有指定,则I / O操作被序列化,即使调用读写功能指定一个OVERLAPPED结构。
FILE_FLAG_POSIX_SEMANTICS
0x01000000A文件是按照POSIX的访问规则。这包括允许多个文件的名称,只在不同的情况下,对文件系统,支持这一命名。时请务必小心使用此选项,因为文件与此标志创建的可能无法访问的应用程序的编写的MS - DOS或16位Windows。
FILE_FLAG_RANDOM_ACCESS
0x10000000A文件是随机访问。该系统可以使用提示此文件缓存优化。
FILE_FLAG_SEQUENTIAL_SCAN
0x08000000A顺序访问文件从开始到结束。该系统可以使用提示此文件缓存优化。如果应用程序移动的随机存取文件指针,优化缓存可能不会发生。但是,正确的操作仍然是保障。
指定这个标志可以提高应用软件的性能阅读使用顺序访问大型文件。性能收益可以更加明显的应用主要是大文件的读取顺序,但偶尔跳过小范围的字节。
FILE_FLAG_WRITE_THROUGH全方位
0x80000000The系统写入任何中间缓存并直接用于磁盘。
如果FILE_FLAG_NO_BUFFERING也没有指定,使系统缓存的效果,然后数据被写入到系统缓存,但立即刷新到磁盘。
如果还指定了FILE_FLAG_NO_BUFFERING,使系统缓存没有生效,然后数据被立即刷新到磁盘而不需要通过系统缓存此案。该操作系统还要求一个写通过硬盘缓存持久性媒体。然而,并不是所有的硬件支持,通过这写能力。
返回值
如果函数成功,返回值是一个开放的句柄指定的文件。
如果函数失败,返回值是INVALID_HANDLE_VALUE。为了获得更多错误信息,调用GetLastError。
备注
使用CloseHandle函数关闭对象句柄的OpenFileById回报。
如果您调用一个文件之前,作为先前调用结果的DeleteFile删除OpenFileById,功能失败。该操作系统的延迟发布文件删除,直到所有的文件句柄关闭。 GetLastError返回ERROR_ACCESS_DENIED。
要求:
client最低支持Vista
server最低支持 Windows Server 2008
RedistributableWindows SDK的在Windows Server 2003和Windows XP。
HeaderWinBase.h(头文件:winuser.h),在Windows Server 2003和Windows XP的FileExtd.h
LibraryKernel32.lib,在Windows Server 2003和Windows XP的FileExtd.lib
DLLKernel32.dll
参见
文件管理函数
CreateFile
CloseHandle
的DeleteFile
GetFileInformationByHandleEx
GetOverlappedResult
OpenFile
ReadFile
WriteFile
ACCESS_MASK
FILE_ID_DESCRIPTOR
的OVERLAPPED
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==OpenFileById Function
Opens the file that matches the specified identifier.
Syntax
C++
HANDLE WINAPI OpenFileById(
__in HANDLE hFile,
__in LPFILE_ID_DESCRIPTOR lpFileID,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes,
__in DWORD dwFlags
);
Parameters
hFile [in]
A handle to any file on a volume or share on which the file to be opened is stored.
lpFileID [in]
A pointer to a FILE_ID_DESCRIPTOR that identifies the file to open.
dwDesiredAccess [in]
The access to the object. Access can be read, write, or both.
For more information, see File Security and Access Rights . You cannot request an access mode that conflicts with the sharing mode that is specified in an open request that has an open handle.
If this parameter is zero (0), the application can query file and device attributes without accessing a device. This is useful for an application to determine the size of a floppy disk drive and the formats it supports without requiring a floppy in a drive. It can also be used to test for the existence of a file or directory without opening them for read or write access.
dwShareMode [in]
The sharing mode of an object, which can be read, write, both, or none.
You cannot request a sharing mode that conflicts with the access mode that is specified in an open request that has an open handle, because that would result in the following sharing violation: (ERROR_SHARING_VIOLATION). For more information, see Creating and Opening Files .
If this parameter is zero (0) and OpenFileById succeeds, the object cannot be shared and cannot be opened again until the handle is closed. For more information, see the Remarks section of this topic.
The sharing options remain in effect until you close the handle to an object.
To enable a processes to share an object while another process has the object open, use a combination of one or more of the following values to specify the access mode they can request to open the object.
ValueMeaning
FILE_SHARE_DELETE
0x00000004Enables subsequent open operations on an object to request delete access.
Otherwise, other processes cannot open the object if they request delete access.
If this flag is not specified, but the object has been opened for delete access, the function fails.
FILE_SHARE_READ
0x00000001Enables subsequent open operations on an object to request read access.
Otherwise, other processes cannot open the object if they request read access.
If this flag is not specified, but the object has been opened for read access, the function fails.
FILE_SHARE_WRITE
0x00000002Enables subsequent open operations on an object to request write access.
Otherwise, other processes cannot open the object if they request write access.
If this flag is not specified, but the object has been opened for write access or has a file mapping with write access, the function fails.

lpSecurityAttributes [in, optional]
Reserved.
dwFlags [in]
The file flags.
When OpenFileById opens a file, it combines the file flags with existing file attributes, and ignores any supplied file attributes. This parameter can include any combination of the following flags.
ValueMeaning
FILE_FLAG_BACKUP_SEMANTICS
0x02000000A file is being opened for a backup or restore operation. The system ensures that the calling process overrides file security checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME privileges. For more information, see Changing Privileges in a Token .
You must set this flag to obtain a handle to a directory. A directory handle can be passed to some functions instead of a file handle. For more information, see Directory Handles .
FILE_FLAG_NO_BUFFERING
0x20000000The system opens a file with no system caching. This flag does not affect hard disk 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 more time, because data is not being held in the cache. Also, the file metadata may still be cached. To flush the metadata to disk, use the FlushFileBuffers function.
An application must meet certain requirements when working with files that are opened with FILE_FLAG_NO_BUFFERING:
File access must begin at byte offsets within a 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, which means 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's 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
0x00100000The file data is requested, but it should continue to be located in remote storage. It should not be transported back to local storage. This flag is for use by remote storage systems.
FILE_FLAG_OPEN_REPARSE_POINT
0x00200000When this flag is used, normal reparse point processing does not occur, and OpenFileById 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
0x40000000The file is being opened or created for asynchronous I/O. When the operation is complete, the event specified to the call in the OVERLAPPED structure is set to the signaled state. Operations that take a significant amount of time to process return ERROR_IO_PENDING.
If this flag is specified, the file can be used for simultaneous read and write operations. The system does not maintain the file pointer, therefore you must pass the file position to the read and write functions in the OVERLAPPED structure or update the file pointer.
If this flag is not specified, then I/O operations are serialized, even if the calls to the read and write functions specify an OVERLAPPED structure.
FILE_FLAG_POSIX_SEMANTICS
0x01000000A file is accessed according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support that naming. Use care when using this option, because files created with this flag may not be accessible by applications that are written for MS-DOS or 16-bit Windows.
FILE_FLAG_RANDOM_ACCESS
0x10000000A file is accessed randomly. The system can use this as a hint to optimize file caching.
FILE_FLAG_SEQUENTIAL_SCAN
0x08000000A file is 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
0x80000000The system writes through any intermediate cache and goes directly to disk.
If FILE_FLAG_NO_BUFFERING is not also specified, so that system caching is in effect, then the data is written to the system cache, but is flushed to disk without delay.
If FILE_FLAG_NO_BUFFERING is also specified, so that system caching is not in effect, then the data is immediately flushed to disk without going through the system cache. The operating system also requests a write-through the hard disk cache to persistent media. However, not all hardware supports this write-through capability.

Return Value
If the function succeeds, the return value is an open handle to a specified file.
If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError .
Remarks
Use the CloseHandle function to close an object handle that OpenFileById returns.
If you call OpenFileById on a file that is pending deletion as a result of a previous call to DeleteFile , the function fails. The operating system delays file deletion until all handles to the file are closed. GetLastError returns ERROR_ACCESS_DENIED.
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
RedistributableWindows SDK on Windows Server 2003 and Windows XP.
HeaderWinBase.h (include Windows.h), FileExtd.h on Windows Server 2003 and Windows XP
LibraryKernel32.lib, FileExtd.lib on Windows Server 2003 and Windows XP
DLLKernel32.dll
See Also
File Management Functions
CreateFile
CloseHandle
DeleteFile
GetFileInformationByHandleEx
GetOverlappedResult
OpenFile
ReadFile
WriteFile
ACCESS_MASK
FILE_ID_DESCRIPTOR
OVERLAPPED
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365432(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:17:42