在Windows / MinGW的,什么是的fcntl(FD,F_GETFL)的`相当于| O_ACCMODE`? [英] On Windows/mingw, what is the equivalent of `fcntl(fd, F_GETFL) | O_ACCMODE`?
问题描述
我编译Windows上的程序使用MinGW。我怎样才能获得访问模式打开的文件描述符?
I am compiling a program on Windows with Mingw. How can I get the access mode for an open file descriptor?
推荐答案
据WIN32.HLP,该API提供的功能 BOOL GetFileInformationByHandle(HANDLE HFILE,LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
在KERNEL32。 LPBY_HANDLE_FILE_INFORMATION
是 BY_HANDLE_FILE_INFORMATION *
,其中 BY_HANDLE_FILE_INFORMATION
如下:
According to Win32.hlp, the API supplies the function BOOL GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
in KERNEL32. LPBY_HANDLE_FILE_INFORMATION
is a BY_HANDLE_FILE_INFORMATION*
, where BY_HANDLE_FILE_INFORMATION
is as follows:
typedef struct _BY_HANDLE_FILE_INFORMATION { // bhfi
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD dwVolumeSerialNumber;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
DWORD nNumberOfLinks;
DWORD nFileIndexHigh;
DWORD nFileIndexLow;
} BY_HANDLE_FILE_INFORMATION;
表示调用函数,如果返回true后, BY_HANDLE_FILE_INFORMATION
包含数据相关的文件。 dwFileAttributes
可以包含 FILE_ATTRIBUTE_READ_ONLY
标记。
After calling said function, if it returns true, the BY_HANDLE_FILE_INFORMATION
contains data pertinent to your file. dwFileAttributes
may contain the FILE_ATTRIBUTE_READ_ONLY
flag.
如果您想不止于此,还有:
If you want more than that, there is also:
BOOL GetKernelObjectSecurity(
HANDLE Handle, // handle of object to query
SECURITY_INFORMATION RequestedInformation, // requested information
PSECURITY_DESCRIPTOR pSecurityDescriptor, // address of security descriptor
DWORD nLength, // size of buffer for security descriptor
LPDWORD lpnLengthNeeded // address of required size of buffer
);
该API的参考是什么 SECURITY_DESCRIPTOR
必然是模糊的,但你可以使用它的地址作为参数来获取特定的属性叫一堆其他的功能。在 SECURITY_INFORMATION
只是一个 DWORD
常量,它的这些功能,你打算调用指定。您可以在 http://msdn.microsoft获取更多.COM / EN-US /库/ aa446641%28VS.85%29.aspx
The API reference is necessarily vague on what a SECURITY_DESCRIPTOR
is, but you can call a bunch of other functions using its address as a parameter to get specific properties. The SECURITY_INFORMATION
is just a DWORD
constant specifying which of these functions you plan to call. You can find more info at http://msdn.microsoft.com/en-us/library/aa446641%28VS.85%29.aspx
编辑 - 第二code节不断冒出来寻找扭曲,但如果你需要,如果你周围挖了一下去链接到API的参考将带领您
Edit - the second code section keeps coming out looking screwy, but the link to the API reference will lead you where you need to go if you dig around a bit.
这篇关于在Windows / MinGW的,什么是的fcntl(FD,F_GETFL)的`相当于| O_ACCMODE`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!