home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / APPTYPE.ZIP / apptype.c next >
C/C++ Source or Header  |  1993-03-24  |  2KB  |  65 lines

  1. /* apptype.c */
  2.  
  3. /* Written by Eberhard Mattes and put into the public domain */
  4.  
  5. #define INCL_DOSSESMGR
  6. #define INCL_DOSERRORS
  7. #include <os2.h>
  8. #include <stdio.h>
  9.  
  10. int main (int argc, char *argv[])
  11. {
  12.   int result, i;
  13.   ULONG rc, type;
  14.  
  15. #ifdef __EMX__
  16.   _wildcard (&argc, &argv);
  17. #endif
  18.   result = 0;
  19.   if (argc < 2)
  20.     {
  21.       puts ("Usage: apptype <program>...");
  22.       return (1);
  23.     }
  24.   for (i = 1; i < argc; ++i)
  25.     {
  26.       rc = DosQueryAppType (argv[i], &type);
  27.       if (rc == ERROR_INVALID_EXE_SIGNATURE)
  28.         fprintf (stderr, "%s: not an executable file\n", argv[i]);
  29.       else if (rc == ERROR_FILE_NOT_FOUND)
  30.         fprintf (stderr, "%s: not found\n", argv[i]);
  31.       else if (rc == ERROR_ACCESS_DENIED)
  32.         fprintf (stderr, "%s: access denied\n", argv[i]);
  33.       else if (rc != 0)
  34.         fprintf (stderr, "%s: error code = %lu\n", argv[i], rc);
  35.       else
  36.         {
  37.           printf ("%s:", argv[i]);
  38.           if (type & FAPPTYP_32BIT)
  39.             printf (" 32-bit");
  40.           if (type & FAPPTYP_PHYSDRV)
  41.             printf (" physical device driver");
  42.           else if (type & FAPPTYP_VIRTDRV)
  43.             printf (" virtual device driver");
  44.           else if (type & FAPPTYP_DLL)
  45.             {
  46.               if (type & FAPPTYP_PROTDLL)
  47.                 printf (" protected");
  48.               printf (" DLL");
  49.             }
  50.           else if (type & (FAPPTYP_WINDOWSREAL|FAPPTYP_WINDOWSPROT))
  51.             printf ("Windows executable");
  52.           else if (type & FAPPTYP_DOS)
  53.             printf (" DOS executable");
  54.           else if (type & FAPPTYP_BOUND)
  55.             printf (" bound executable");
  56.           else if ((type & 7) == FAPPTYP_WINDOWAPI)
  57.             printf (" PM executable");
  58.           else
  59.             printf (" OS/2 executable");
  60.           putchar ('\n');
  61.         }
  62.     }
  63.   return (0);
  64. }
  65.