[C] 打开一共享文件 →→→→→进入此内容的聊天室

来自 , 2020-07-30, 写在 C, 查看 101 次.
URL http://www.code666.cn/view/68d30981
  1. #include <io.h>
  2. #include <fcntl.h>
  3. #include <sys\stat.h>
  4. #include <process.h>
  5. #include <share.h>
  6. #include <stdio.h>
  7.  
  8. int main(void)
  9. {
  10.    int handle;
  11.    int status;
  12.  
  13.    handle = sopen("c:\\autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD);
  14.  
  15.    if (!handle)
  16.    {
  17.       printf("sopen failed\n");
  18.       exit(1);
  19.    }
  20.  
  21.    status = access("c:\\autoexec.bat", 6);
  22.    if (status == 0)
  23.       printf("read/write access allowed\n");
  24.    else
  25.       printf("read/write access not allowed\n");
  26.  
  27.    close(handle);
  28.    return 0;
  29. }

回复 "打开一共享文件"

这儿你可以回复上面这条便签

captcha