From EDM2
Jump to: navigation, search

Returns the application type of an executable file.


DosQueryAppType(pszName, pFlags)


pszName (PSZ) - input 
An ASCIIZ string that contains the file name of the executable file for which the flags are to be returned.
If the string appears to be a fully qualified path (that is, it contains a ":" in the second position, or it contains a "\", or both), then the file is located in the indicated drive:directory. If neither of these is true, and this file name is not found in the current directory, each drive:directory specification in the path defined in the current program's environment is searched for this file. Note that any extension (.xxx) is acceptable for the executable file name. If no extension is specified, a default extension of ".exe" is used.
pFlags (PULONG) - output 
A doubleword that will contain flags denoting the application type, as determined by reading the executable file header specified by pszName. Note that the call sequence passes a pointer to a location in application memory to return the application type flags.
pFlags is defined as follows:
Bit Description
2-0 Indicate the application type as specified in the header:
000 FAPPTYP_NOTSPEC (0x00000000) Application type is not specified in the executable header.
001 FAPPTYP_NOTWINDOWCOMPAT (0x00000001) Application type is not-window-compatible.
010 FAPPTYP_WINDOWCOMPAT (0x00000002) Application type is window-compatible.
011 FAPPTYP_WINDOWAPI (0x00000003) Application type is window-API.
3 FAPPTYP_BOUND (0x00000008)

Set to 1 if the executable file has been "bound" (by the BIND command) as a Family API application. Bits 0, 1, and 2 still apply.

4 FAPPTYP_DLL (0x00000010)

Set to 1 if the executable file is a dynamic link library (DLL) module. Bits 0, 1, 2, 3, and 5 will be set to 0.

5 FAPPTYP_DOS (0x00000020)

Set to 1 if the executable file is in PC/DOS format. Bits 0, 1, 2, 3, and 4 will be set to 0.

6 FAPPTYP_PHYSDRV (0x00000040)

Set to 1 if the executable file is a physical device driver.

7 FAPPTYP_VIRTDRV (0x00000080)

Set to 1 if the executable file is a virtual device driver.

8 FAPPTYP_PROTDLL (0x00000100)

Set to 1 if the executable file is a protected-memory dynamic link library module.

9-13 Reserved.
14 FAPPTYP_32BIT (0x00004000)

Set to 1 for 32-bit executable files.

15 Reserved.

Return Code

ulrc (APIRET) - returns

DosQueryAppType returns one of the following values:

  • 0 NO_ERROR


DosQueryAppType returns the application type of an executable file.

The Presentation Manager shell uses this function to determine the application type that is being executed.

The application type is specified at link time in the module definition file.

Example Code

This example shows how to obtain the application type of an executable file.

#define INCL_DOSSESMGR   /* Session Manager values */
#define INCL_DOSERRORS   /* DOS error values       */
#include <os2.h>
#include <stdio.h>

int main (VOID) {
   PSZ      szAppName = "C:\\OS2\\SYSLOG.EXE";  /* Application name      */
   ULONG    AppType = 0;            /* Application type flags (returned) */
   APIRET   rc      = NO_ERROR;     /* Return code                       */

   rc = DosQueryAppType(szAppName, &AppType);
                     /* On successful return, the AppType      */
                     /*   variable contains a set of bit flags */
                     /*   that describe the application type   */
                     /*   of the specified executable file     */

   if (rc != NO_ERROR) {
      printf("DosQueryAppType error: return code = %u\n", rc);
      return 1;
   } else {
    printf("Appname = %s\n", szAppName);
    printf("Apptype = %d\n", AppType & FAPPTYP_EXETYPE);
    printf(" Window API?     %s\n", (AppType & FAPPTYP_WINDOWAPI) ? "Y" : "N");
    printf(" Window compat?  %s\n", (AppType & FAPPTYP_WINDOWCOMPAT) ? "Y" : "N");
    printf(" Family API?     %s\n", (AppType & FAPPTYP_BOUND) ? "Y" : "N");
    printf(" PC/DOS format?  %s\n", (AppType & FAPPTYP_DOS) ? "Y" : "N");
    printf(" DLL?            %s\n",
                      (AppType & (FAPPTYP_DLL | FAPPTYP_PROTDLL) ) ? "Y" : "N");
   return NO_ERROR;

Related Functions