Jump to content

DosQueryAppType: Difference between revisions

From EDM2
Created page with "==Description== Returns the application type of an executable file. ==Syntax== <PRE> #define INCL_DOSMODULEMGR #include <os2.h> PSZ pszName; /* An ASCIIZ string that..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
DosQueryAppType returns the application type of an executable file.
Returns the application type of an executable file.


==Syntax==
==Syntax==
<PRE>
DosQueryAppType(pszName, pFlags)
#define INCL_DOSMODULEMGR
#include <os2.h>


PSZ      pszName;  /*  An ASCIIZ string that contains the file name of the executable file for which the flags are to be returned. */
PULONG    pFlags;
APIRET    ulrc;    /*  Return Code. */
ulrc = DosQueryAppType(pszName, pFlags);
</PRE>
==Parameters==
==Parameters==
; pszName (PSZ) - input : An ASCIIZ string that contains the file name of the executable file for which the flags are to be returned.
;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.
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:
; 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.
:{|class="wikitable"
 
!Bit||Description
pFlags is defined as follows:
|-
 
|2-0||Indicate the application type as specified in the header:
Bit       Description  
:000 FAPPTYP_NOTSPEC (0x00000000) Application type is not specified in the executable header.
2-0       Indicate the application type as specified in the header:
:001 FAPPTYP_NOTWINDOWCOMPAT (0x00000001) Application type is not-window-compatible.
 
:010 FAPPTYP_WINDOWCOMPAT (0x00000002) Application type is window-compatible.
000     FAPPTYP_NOTSPEC (0x00000000) Application type is not specified in the executable header.  
:011 FAPPTYP_WINDOWAPI (0x00000003) Application type is window-API.
001           FAPPTYP_NOTWINDOWCOMPAT (0x00000001)
|-
            Application type is not-window-compatible.  
|3||FAPPTYP_BOUND (0x00000008)
010           FAPPTYP_WINDOWCOMPAT (0x00000002)
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.
            Application type is window-compatible.  
|-
011           FAPPTYP_WINDOWAPI (0x00000003)
|4||FAPPTYP_DLL (0x00000010)
            Application type is window-API.  
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.
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.  
|5||FAPPTYP_DOS (0x00000020)
4           FAPPTYP_DLL (0x00000010)
Set to 1 if the executable file is in PC/DOS format. Bits 0, 1, 2, 3, and 4 will be set to 0.
            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)
|6||FAPPTYP_PHYSDRV (0x00000040)
            Set to 1 if the executable file is in PC/DOS format. Bits 0, 1, 2, 3, and 4 will be set to 0.  
Set to 1 if the executable file is a physical device driver.
6           FAPPTYP_PHYSDRV (0x00000040)
|-
            Set to 1 if the executable file is a physical device driver.  
|7||FAPPTYP_VIRTDRV (0x00000080)
7           FAPPTYP_VIRTDRV (0x00000080)
Set to 1 if the executable file is a virtual device driver.
            Set to 1 if the executable file is a virtual device driver.  
|-
8           FAPPTYP_PROTDLL (0x00000100)
|8||FAPPTYP_PROTDLL (0x00000100)
            Set to 1 if the executable file is a protected-memory dynamic link library module.  
Set to 1 if the executable file is a protected-memory dynamic link library module.
9-13           Reserved.  
|-
14           FAPPTYP_32BIT (0x00004000)
|9-13||Reserved.
            Set to 1 for 32-bit executable files.  
|-
15           Reserved.  
|14||FAPPTYP_32BIT (0x00004000)
Set to 1 for 32-bit executable files.
|-
|15||Reserved.
|}


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosQueryAppType returns one of the following values:
 
* 0 NO_ERROR
DosQueryAppType returns one of the following values:
* 2 ERROR_FILE_NOT_FOUND
* 3 ERROR_PATH_NOT_FOUND
* 4 ERROR_TOO_MANY_OPEN_FILES
* 11 ERROR_BAD_FORMAT
* 15 ERROR_INVALID_DRIVE
* 32 ERROR_SHARING_VIOLATION
* 108 ERROR_DRIVE_LOCKED
* 110 ERROR_OPEN_FAILED
* 191 ERROR_INVALID_EXE_SIGNATURE
* 192 ERROR_EXE_MARKED_INVALID


* 0    NO_ERROR
* 2        ERROR_FILE_NOT_FOUND
* 3        ERROR_PATH_NOT_FOUND
* 4        ERROR_TOO_MANY_OPEN_FILES
* 11        ERROR_BAD_FORMAT
* 15        ERROR_INVALID_DRIVE
* 32        ERROR_SHARING_VIOLATION
* 108        ERROR_DRIVE_LOCKED
* 110        ERROR_OPEN_FAILED
* 191        ERROR_INVALID_EXE_SIGNATURE
* 192        ERROR_EXE_MARKED_INVALID
==Remarks==
==Remarks==
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 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.


The application type is specified at link time in the module definition file.
==Example Code==
==Example Code==
This example shows how to obtain the application type of an executable file.
This example shows how to obtain the application type of an executable file.
Line 106: Line 97:
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosLoadModule|DosLoadModule]]
*[[DosLoadModule]]
* [[OS2 API:CPI:DosQueryProcType|DosQueryProcType]]
*[[DosQueryProcType]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 02:43, 5 June 2021

DosQueryAppType returns the application type of an executable file.

Syntax

DosQueryAppType(pszName, pFlags)

Parameters

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
  • 2 ERROR_FILE_NOT_FOUND
  • 3 ERROR_PATH_NOT_FOUND
  • 4 ERROR_TOO_MANY_OPEN_FILES
  • 11 ERROR_BAD_FORMAT
  • 15 ERROR_INVALID_DRIVE
  • 32 ERROR_SHARING_VIOLATION
  • 108 ERROR_DRIVE_LOCKED
  • 110 ERROR_OPEN_FAILED
  • 191 ERROR_INVALID_EXE_SIGNATURE
  • 192 ERROR_EXE_MARKED_INVALID

Remarks

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