sopen.c

来自「vc library 韩国语版 希望对大家又帮助」· C语言 代码 · 共 31 行

C
31
字号
 #include <io.h>
 #include <fcntl.h>
 #include <sys\stat.h>
 #include <process.h>
 #include <share.h>
 #include <stdio.h>

 int main(void)
 {
    int handle;
    int status;

    handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, 
S_IREAD);

    if (!handle)
    {
       printf("sopen failed\n");
       exit(1);
    }

    status = access("c:\\autoexec.bat", 6);
    if (status == 0)
       printf("read/write access allowed\n");
    else
       printf("read/write access not allowed\n");

    close(handle);
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?