作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
通过将 dwShareMode 设置为 0,我可以使用 CreateFile “独占”打开卷:
#include <windows.h>
int main() {
HANDLE ki = CreateFile("\\\\.\\F:", GENERIC_READ | GENERIC_WRITE, 0,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
我可以使用 fopen 以“共享模式”打开卷:
#include <stdio.h>
int main() {
FILE* ki = fopen("\\\\.\\F:", "r+b");
}
我可以用 open 来“独占”打开一个文件:
#include <stdio.h>
#include <fcntl.h>
int main() {
int ju = open("lima.txt", O_RDWR | O_EXCL);
FILE* ki = fdopen(ju, "r+b");
}
但是,如果我尝试使用 open 打开卷,它将失败:
#include <stdio.h>
#include <fcntl.h>
int main() {
int ju = open("\\\\.\\F:", O_RDWR | O_EXCL);
FILE* ki = fdopen(ju, "r+b");
}
经过测试,无论有或没有 O_EXCL 标志都会发生这种情况。是独家卷打开一些只能用 CreateFile 完成的东西,或者我错过了东西?
最佳答案
根据the standard :
result is undefined if O_RDWR is applied to a FIFO
在这种情况下,卷似乎被识别为 FIFO。修复:
open("\\\\.\\F:", O_RDONLY);
或者:
open("\\\\.\\F:", O_WRONLY);
或者:
open("\\\\.\\F:", O_RDONLY | O_WRONLY);
关于c - 独家开卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37265683/
我正在处理一个页面,其中列表中的所选元素的特点是没有给定的类。类似于以下内容: not selected selected not selected 我想定义一个 CSS 选择器来获取
我正在尝试为我的 iOS 应用创建/导出一个独有的 UTI 类型(非常类似于 Instagram 独占处理 UTI com.instagram.exclusivegram 的方式)。 基本上,我希望
我是一名优秀的程序员,十分优秀!