c

来自「C程序设计经典900例.zip」· 代码 · 共 27 行

TXT
27
字号
#include <stdio.h>
#include <io.h>
#include <share.h>
#include <fcntl.h>
#include <sys\locking.h>

void main(void)
 {
   int handle;

   if ((handle = sopen("\\AUTOEXEC.BAT", O_RDONLY, SH_DENYNO)) == -1)
     printf("Error opening AUTOEXEC.BAT\n");
   else
    {
      printf("Trying to lock file\n");
      if (locking(handle, LK_LOCK, 5L))
         printf("Error locking file\n");
      else
       {
         printf("File locked--press Enter to continue\n");
         getchar();
         close(handle);
       }
    }
 }

⌨️ 快捷键说明

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