home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_03_05 / 3n05030a < prev    next >
Text File  |  1992-03-24  |  2KB  |  67 lines

  1. #define MAIN
  2. #include <dos.h>
  3. #include <string.h>
  4. #include "windows.h"    /* This isn't required ... It was convenient */
  5. /*
  6. ******************************************************************
  7. Title:      PIPEDOS.C - DOS Component of Pipe Interface
  8. Author:     Thomas W. Olsen
  9. Version:    3.0
  10. Compiler:   Microsoft C 6.0
  11.             cl /AL /Gs /Zi /c PIPEDOS.C
  12.             cl /AL /Gs /Zi /c PIPEFUNC.C
  13.             link /CO PIPEDOS PIPEFUNC;
  14. ******************************************************************
  15. */
  16.  
  17. BOOL PASCAL PipeSetup(void);
  18. WORD PASCAL PipeAllocateSelector(WORD segment);
  19. void PASCAL PipeFreeSelector(WORD selector);
  20. BOOL PASCAL PipeCallWindowsProc(WORD message, WORD wParam, LONG lParam);
  21.  
  22. struct _AppInfo
  23. {
  24.     BOOL BusyFlag;
  25.     char Buffer[128];
  26. }
  27. AppInfo;
  28.  
  29. int main(int argc, char *argv[])
  30. {
  31.     WORD  selector;
  32.     LPSTR protectedModePtr;
  33.     union REGS regs;
  34.  
  35.     if (PipeSetup() == TRUE)  /* Find Version & Entrypoint of Pipe */
  36.     {
  37.         AppInfo.BusyFlag = TRUE;
  38.         strcpy(AppInfo.Buffer, "These are the contents of the real mode buffer!");
  39.  
  40.         /* Windows cannot use real mode addresses ... so we need to allocate
  41.            a protected mode GDT selector */
  42.  
  43.         selector         = PipeAllocateSelector(HIWORD(&AppInfo));
  44.         protectedModePtr = (LPSTR) MAKELONG(LOWORD(&AppInfo), selector);
  45.  
  46.         PipeCallWindowsProc(WM_USER,                    /* This function calls the */
  47.                             _fstrlen(AppInfo.Buffer), /* Pipe ... which calls the */
  48.                             (LONG) protectedModePtr);   /* Windows Proc */
  49.  
  50.         /* You cannot do a PipeFreeSelector() until you're certain that the
  51.            Windows proc has used it ... otherwise, you'll get a UAE. Have
  52.            the Windows proc set a flag in the buffer you're passing to it
  53.            which signifies completion. */
  54.  
  55.         while (AppInfo.BusyFlag == TRUE)
  56.             {
  57.            kbhit();            /* Gotta do Something... */
  58.         regs.x.ax = 0x1680;        /* WINDOWS API */
  59.         int86(0x2F, ®s, ®s);    /* Release Time Slice */
  60.         }
  61.  
  62.         PipeFreeSelector(selector);
  63.     }
  64.     else
  65.         printf("Pipe Not Found\n");
  66. }
  67.