home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 14 / getclip.c < prev    next >
C/C++ Source or Header  |  1992-06-03  |  1KB  |  42 lines

  1. /* 
  2. GETCLIP.C -- DOS program gets text from Windows clipboard
  3. requires WINCLIP.C
  4. for example (Borland C++): bcc getclip.c winclip.c
  5.  
  6. Copyright (c) 1992 Ziff Davis Communications
  7. PC Magazine * Andrew Schulman (June 1992)
  8. */
  9.  
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include "winclip.h"
  14.  
  15. void fail(char *s) { fputs(s, stderr); fputs("\n", stderr); exit(1); }
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19.     char *s;
  20.     
  21.     fputs("GETCLIP version 1.0\n", stderr);
  22.     fputs("Copyright (c) 1992 Ziff Davis Communications "
  23.           "* Andrew Schulman\n\n", stderr);
  24.       
  25.     if ((argc > 1) && (argv[1][0]=='/') && (argv[1][1]=='?')) // /?
  26.         fail("GETCLIP retrieves text from the Windows clipboard");
  27.     
  28.     if (! WindowsClipboard())
  29.         fail("This program must run in a DOS box "
  30.              "under Enhanced mode Windows");
  31.  
  32.     if (s = GetClipString())
  33.     {
  34.         puts(s);
  35.         FreeClipString(s);
  36.     }
  37.     else
  38.         puts("* clipboard empty *");
  39.     return 0;
  40. }
  41.  
  42.