NamePipeClient.h 600 B

1234567891011121314151617181920212223242526272829
  1. #ifndef _NAME_PIPE_CLIENT_H
  2. #define _NAME_PIPE_CLIENT_H
  3. #include<windows.h>
  4. #include<iostream>
  5. class NamePipeClient
  6. {
  7. public:
  8. NamePipeClient()
  9. {
  10. pStr = "data from client";
  11. pPipeName = "\\\\.\\pipe\\testPipe";
  12. }
  13. //打开命名管道
  14. void OpenNamedPipeInClient();
  15. //客户端从命名管道中读取数据
  16. void NamedPipeReadInClient();
  17. //客户端往命名管道中写入数据
  18. void NamedPipeWriteInClient();
  19. private:
  20. //用来保存在客户端通过 CreateFile 打开的命名管道句柄HANDLE
  21. HANDLE hNamedPipe;
  22. const char * pStr;
  23. const char * pPipeName;
  24. };
  25. #endif