fork download
  1. /* filename: pclient.c */
  2.  
  3. #define UNICODE
  4.  
  5. #include <windows.h>
  6. #include <stdio.h>
  7.  
  8. int main() {
  9. wchar_t buf[1024];
  10. int numBytes = 0;
  11. BOOL writeGood = FALSE;
  12.  
  13. HANDLE hPipe = NULL;
  14. hPipe = CreateFile(L"\\\\.\\pipe\\purpose",
  15. GENERIC_READ | GENERIC_WRITE,
  16. 0,
  17. NULL,
  18. OPEN_EXISTING,
  19. 0,
  20. NULL);
  21.  
  22. if (hPipe == INVALID_HANDLE_VALUE) {
  23. _putws(L"hPipe error.\n");
  24. return 0;
  25. }
  26.  
  27. writeGood = WriteFile(hPipe, L"AAAAAAAAAAAAAAAA", 32, &numBytes, NULL);
  28. printf("numBytes for writefile = %d\n", numBytes);
  29. if (writeGood == FALSE) return 0;
  30. Sleep(500);
  31.  
  32. writeGood = WriteFile(hPipe, L"BBBBBBBBBBBBBBBB", 32, &numBytes, NULL);
  33. printf("numBytes for writefile = %d\n", numBytes);
  34. if (writeGood == FALSE) return 0;
  35. Sleep(500);
  36.  
  37. writeGood = WriteFile(hPipe, L"C", 4, &numBytes, NULL);
  38. printf("numBytes for writefile = %d\n", numBytes);
  39.  
  40. _putws(L"all done, stop...");
  41. system("pause");
  42. CloseHandle(hPipe);
  43. return 0;
  44. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty