home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP6.ZIP / FPRTNAME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.6 KB  |  62 lines

  1. /*
  2.     FPRTNAME.C -- Demonstrates GetFilePortName
  3.  
  4.     From Chapter 6 of "Undocumented Windows" (Addison-Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.  
  7.     Build using: WINIOBC FPRTNAME (for Borland C++ v3.00)
  8.                  WINIOMS FPRTNAME (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h> 
  12. #include <string.h>
  13. #include "winio.h" 
  14.  
  15. /* undocumented function */ 
  16. extern WORD FAR PASCAL GetFilePortName(LPOFSTRUCT lpofstruct);
  17.  
  18. #include "checkord.c"
  19.  
  20. int main() 
  21.     {
  22.     WORD wRet;
  23.     OFSTRUCT ofstruct;
  24.  
  25.     if (! CheckOrdName("GetFilePortName", "USER", 343))
  26.         return 0;
  27.  
  28.     winio_about("FPRTNAME"
  29.         "\nDemonstrates GetFilePortName"
  30.         "\n\nFrom Chapter 6 of"
  31.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  32.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  33.         );
  34.     
  35.     winio_setecho(winio_current(), FALSE);
  36.  
  37.     for (;;)
  38.         {
  39.         wRet = GetFilePortName((LPOFSTRUCT) &ofstruct);
  40.  
  41.         printf("GetFilePortName returned %d\n", wRet);
  42.         if (wRet == 1)
  43.             printf(
  44.                 "In the OFSTRUCT:\n"
  45.                 "structure length: %d\n"
  46.                 "fixed disk file : %s\n"
  47.                 "dos error code  : %d\n"
  48.                 "full file name  : %s\n",
  49.                 ofstruct.cBytes,
  50.                 ofstruct.fFixedDisk ? "Yes" : "No",
  51.                 ofstruct.nErrCode,
  52.                 ofstruct.szPathName);
  53.         
  54.         printf("\nPress a key to do it again\n"
  55.             "or close the window to exit\n\n");
  56.     
  57.         getchar();
  58.         }
  59.             
  60.     return 0;
  61.     }
  62.