home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / s / servic.zip / CLIENT.C next >
C/C++ Source or Header  |  1993-02-08  |  1KB  |  49 lines

  1. ////////////////////////////////////////////////////////
  2. //
  3. //  Client.c --
  4. //
  5. //      This program is a command line oriented
  6. //      demonstration of the Simple service
  7. //      sample.
  8. //
  9. //      Copyright 1993, Microsoft Corp.  All Rights Reserved
  10. //
  11. //  history:
  12. //
  13. //      who         when            what
  14. //      ---         ----            ----
  15. //      davidbro    2/3/93          creation
  16. //
  17. #include <windows.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21.  
  22. VOID
  23. main(int argc, char *argv[])
  24. {
  25.     char    inbuf[80];
  26.     char    outbuf[80];
  27.     DWORD   bytesRead;
  28.     BOOL    ret;
  29.  
  30.     if (argc != 3) {
  31.         printf("usage: client <pipename> <string>\n");
  32.         exit(1);
  33.     }
  34.  
  35.     strcpy(outbuf, argv[2]);
  36.  
  37.     ret = CallNamedPipe(argv[1], outbuf, sizeof(outbuf),
  38.                                  inbuf, sizeof(inbuf),
  39.                                  &bytesRead, NMPWAIT_WAIT_FOREVER);
  40.  
  41.     if (!ret) {
  42.         printf("client: CallNamedPipe failed, GetLastError = %d\n",
  43.                 GetLastError());
  44.         exit(1);
  45.     }
  46.  
  47.     printf("client: received: %s\n", inbuf);
  48. }
  49.