网站首页  词典首页

请输入您要查询的函数:

 

术语 openfile
释义 OpenFile
语法:
C++
HFILE WINAPI OpenFile(
__in LPCSTR lpFileName,
__out LPOFSTRUCT lpReOpenBuff,
__in UINT uStyle
);
OpenFile函数
创建,打开,重新打开或删除文件。
注意:只有使用此功能的16位的Windows版本。对于新的应用程序,使用CreateFile函数。
参数
lpFileName [in]
该文件的名称。
该字符串包含的字符必须从Windows字符集。该OpenFile函数不支持Unicode文件名或打开命名管道。
lpReOpenBuff [out]
向OFSTRUCT结构,收到约1时,第一个打开的文件信息的指针。
该结构可用于函数的OpenFile后续调用看到一个打开的文件。
该OFSTRUCT结构包含一个是限制OFS_MAXPATHNAME字符,它的长度是128个字符的路径字符串的成员。正因为如此,您不能使用OpenFile函数打开的路径长度超过128个字符的文件。 CreateFile函数没有这个路径长度的限制。
uStyle [in]
该采取的行动。
此参数可以是一个或多个下列值。
ValueMeaning
OF_CANCEL
0x00000800Ignored。
为了产生一个对话框,包含一个取消按钮,使用OF_PROMPT。
OF_CREATE
0x00001000Creates一个新的文件。
如果该文件存在,它被截断为零(0)的长度。
OF_DELETE
0x00000200Deletes文件。
OF_EXIST
0x00004000Opens一个文件,然后关闭它。
使用此测试文件的存在。
OF_PARSE
0x00000100Fills的OFSTRUCT结构,但并没有做别的事。
OF_PROMPT
0x00002000Displays一个对话框,如果一个请求的文件不存在。
一个对话框,通知用户,该系统无法找到一个文件,它包含重试和取消按钮。取消按钮指示OpenFile返回文件未发现的错误信息。
OF_READ
0x00000000Opens为只读文件。
OF_READWRITE
0x00000002Opens与读文件/写权限。
OF_REOPEN
0x00008000Opens通过使用信息在缓冲区重新打开一个文件。
OF_SHARE_COMPAT
0x00000000For的MS - DOS的文件系统,打开一个文件的兼容模式,可以对指定的计算机程序来打开该文件任意多次。
其他努力打开一个共享的模式与其他文件失败。这个标志是映射到FILE_SHARE_READ | FILE_SHARE_WRITE CreateFile函数的标志。
OF_SHARE_DENY_NONE
0x00000040Opens不否认读或写访问其他进程的文件。
在MS - DOS的文件系统,如果该文件已经在兼容模式打开任何其他程序,函数失败。
这个标志是映射到FILE_SHARE_READ | FILE_SHARE_WRITE CreateFile函数的标志。
OF_SHARE_DENY_READ
0x00000030Opens一个文件,并否认读访问其他进程。
在MS - DOS的文件系统,如果该文件已经在兼容模式下,或阅读任何其他进程访问方式打开,该功能失败。
这个标志是映射到CreateFile函数FILE_SHARE_WRITE标志。
OF_SHARE_DENY_WRITE
0x00000020Opens一个文件,并否认写入访问其他进程。
在MS - DOS的文件系统,如果一个文件已在兼容模式下,写入或打开任何其他程序的途径,功能失败。
这个标志是映射到CreateFile函数FILE_SHARE_READ标志。
OF_SHARE_EXCLUSIVE
0x00000010Opens以独占模式打开文件,并否认都读/写访问其他进程。如果一个文件被打开任何其他方式进行读/即使是当前进程写访问,功能失败。
OF_VERIFYVerifies的日期和文件的时间是一样的在打开时以前。
这项很有作为只读文件额外的检查。
OF_WRITE
0x00000001Opens写访问一个唯一的文件。
返回值
如果函数成功,返回值指定一个文件句柄。
如果函数失败,返回值是HFILE_ERROR。为了获得更多错误信息,调用GetLastError。
备注
如果lpFileName参数指定一个文件名和扩展名,为在以下目录中匹配的文件和命令显示这个功能搜索:
该目录的应用程序加载。
当前目录。
Windows系统目录中。
使用GetSystemDirectory函数获得这个目录的路径。
16位Windows系统目录。
没有一个函数检索此目录的路径,但它是搜索。
Windows目录。
使用GetWindowsDirectory函数获得这个目录的路径。
即是在PATH环境变量中列出的目录。
该lpFileName参数不能包含通配符。
该OpenFile函数不支持OF_SEARCH标志的16位Windows OpenFile函数支持。在OF_SEARCH标志指示系统匹配的搜索文件,即使一个文件名包含完整路径。使用SearchPath功能的文件搜索。
出现共享冲突如果试图打开远程机器上的文件或目录的删除时,该uStyle参数的值是OF_DELETE访问国旗与其他旗帜访问或运算,远程文件或目录未陆续展开FILE_SHARE_DELETE共享访问。为了避免在这种情况下共享冲突,打开远程文件或OF_DELETE访问目录只,或调用没有首先打开的DeleteFile文件或目录的删除。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateFile
文件管理函数
GetSystemDirectory
GetWindowsDirectory
OFSTRUCT
SearchPath
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==OpenFile Function
Creates, opens, reopens, or deletes a file.
Note Only use this function with 16-bit versions of Windows. For newer applications, use the CreateFile function.
Syntax
C++
HFILE WINAPI OpenFile(
__in LPCSTR lpFileName,
__out LPOFSTRUCT lpReOpenBuff,
__in UINT uStyle
);
Parameters
lpFileName [in]
The name of the file.
The string must consist of characters from the Windows character set. The OpenFile function does not support Unicode file names or opening named pipes.
lpReOpenBuff [out]
A pointer to the OFSTRUCT structure that receives information about a file when it is first opened.
The structure can be used in subsequent calls to the OpenFile function to see an open file.
The OFSTRUCT structure contains a path string member with a length that is limited to OFS_MAXPATHNAME characters, which is 128 characters. Because of this, you cannot use the OpenFile function to open a file with a path length that exceeds 128 characters. The CreateFile function does not have this path length limitation.
uStyle [in]
The action to be taken.
This parameter can be one or more of the following values.
ValueMeaning
OF_CANCEL
0x00000800Ignored.
To produce a dialog box containing a Cancel button, use OF_PROMPT.
OF_CREATE
0x00001000Creates a new file.
If the file exists, it is truncated to zero (0) length.
OF_DELETE
0x00000200Deletes a file.
OF_EXIST
0x00004000Opens a file and then closes it.
Use this to test for the existence of a file.
OF_PARSE
0x00000100Fills the OFSTRUCT structure, but does not do anything else.
OF_PROMPT
0x00002000Displays a dialog box if a requested file does not exist.
A dialog box informs a user that the system cannot find a file, and it contains Retry and Cancel buttons. The Cancel button directs OpenFile to return a file-not-found error message.
OF_READ
0x00000000Opens a file for reading only.
OF_READWRITE
0x00000002Opens a file with read/write permissions.
OF_REOPEN
0x00008000Opens a file by using information in the reopen buffer.
OF_SHARE_COMPAT
0x00000000For MS-DOS–based file systems, opens a file with compatibility mode, allows any process on a specified computer to open the file any number of times.
Other efforts to open a file with other sharing modes fail. This flag is mapped to the FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.
OF_SHARE_DENY_NONE
0x00000040Opens a file without denying read or write access to other processes.
On MS-DOS-based file systems, if the file has been opened in compatibility mode by any other process, the function fails.
This flag is mapped to the FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.
OF_SHARE_DENY_READ
0x00000030Opens a file and denies read access to other processes.
On MS-DOS-based file systems, if the file has been opened in compatibility mode, or for read access by any other process, the function fails.
This flag is mapped to the FILE_SHARE_WRITE flag of the CreateFile function.
OF_SHARE_DENY_WRITE
0x00000020Opens a file and denies write access to other processes.
On MS-DOS-based file systems, if a file has been opened in compatibility mode, or for write access by any other process, the function fails.
This flag is mapped to the FILE_SHARE_READ flag of the CreateFile function.
OF_SHARE_EXCLUSIVE
0x00000010Opens a file with exclusive mode, and denies both read/write access to other processes. If a file has been opened in any other mode for read/write access, even by the current process, the function fails.
OF_VERIFYVerifies that the date and time of a file are the same as when it was opened previously.
This is useful as an extra check for read-only files.
OF_WRITE
0x00000001Opens a file for write access only.

Return Value
If the function succeeds, the return value specifies a file handle.
If the function fails, the return value is HFILE_ERROR. To get extended error information, call GetLastError .
Remarks
If the lpFileName parameter specifies a file name and extension only, this function searches for a matching file in the following directories and the order shown:
The directory where an application is loaded.
The current directory.
The Windows system directory.
Use the GetSystemDirectory function to get the path of this directory.
The 16-bit Windows system directory.
There is not a function that retrieves the path of this directory, but it is searched.
The Windows directory.
Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
The lpFileName parameter cannot contain wildcard characters.
The OpenFile function does not support the OF_SEARCH flag that the 16-bit Windows OpenFile function supports. The OF_SEARCH flag directs the system to search for a matching file even when a file name includes a full path. Use the SearchPath function to search for a file.
A sharing violation occurs if an attempt is made to open a file or directory for deletion on a remote machine when the value of the uStyle parameter is the OF_DELETE access flag OR'ed with any other access flag, and the remote file or directory has not been opened with FILE_SHARE_DELETE share access. To avoid the sharing violation in this scenario, open the remote file or directory with OF_DELETE access only, or call DeleteFile without first opening the file or directory for deletion.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateFile
File Management Functions
GetSystemDirectory
GetWindowsDirectory
OFSTRUCT
SearchPath
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365430(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:21:36