[C.C++] 写一段监视剪贴板内容的程序

1340 0
狼毛 2023-8-25 20:22:45 | 显示全部楼层 |阅读模式
  1. //写一段监视剪贴板内容的程序
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <sys/types.h>
  6. #include <sys/stat.h>
  7. #include <fcntl.h>
  8. #include <unistd.h>
  9. #include <sys/select.h>
  10. #include <sys/time.h>
  11. #include <sys/mman.h>
  12. #include <sys/wait.h>
  13. #include <errno.h>
  14. #include <signal.h>
  15. #include <pthread.h>
  16. #include <semaphore.h>


  17. int main(int argc, char *argv[])
  18. {
  19.     int fd = open("/dev/clipboard", O_RDONLY);
  20.     if(fd < 0)
  21.     {
  22.         perror("open");
  23.         return -1;

  24.     }
  25.     char buf[1024];
  26.     while(1)
  27.     {
  28.         memset(buf, 0, sizeof(buf));
  29.         read(fd, buf, sizeof(buf));
  30.         printf("%s\n", buf);
  31.         sleep(1000);
  32.     }
  33.     return 0;

  34.     }
  35.                
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

狼毛

精英红客

关注
  • 206
    主题
  • 2
    粉丝
  • 1
    关注
这家伙很懒,什么都没留下!

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行