home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a120 / 1.ddi / WATCOM_C / WAT109.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-07  |  934 b   |  43 lines

  1. /*------------------------------------------------------------------*/
  2. /* ╡{ªí└╔ªW║┘: wat109.c                                             */
  3. /*------------------------------------------------------------------*/
  4. #include <io.h>
  5. #include <fcntl.h>
  6. #include <sys\stat.h>
  7. #include <process.h>
  8. #include <share.h>
  9. #include <stdio.h>
  10.  
  11. void main()
  12. {
  13.    int handle, lock_stat;
  14.    long size;
  15.  
  16.    /* Ñ▓╢╖Ѳ╕ⁿñJ DOS ñº share.exe */
  17.    handle = sopen("c:\\config.sys",
  18.       O_RDONLY,SH_DENYNO,S_IREAD);
  19.  
  20.    if (!handle)
  21.    {
  22.       printf("sopen() ¿τ╝╞╢}└╔Ñó▒╤\n");
  23.       exit(1);
  24.    }
  25.  
  26.    size = filelength(handle);
  27.    lock_stat = locking(handle,0L,size/2);
  28.  
  29.    if (lock_stat == 0)
  30.       printf("ª¿Ñ\ªa┬Ω⌐w\n");
  31.    else
  32.       printf("┬Ω⌐wÑó▒╤\n");
  33.  
  34.    lock_stat = unlock(handle,0L,size/2);
  35.  
  36.    if (lock_stat == 0)
  37.       printf("ª¿Ñ\ªa╕╤┬Ω\n");
  38.    else
  39.       printf("╕╤┬ΩÑó▒╤\n");
  40.  
  41.    close(handle);
  42. }
  43.