DosQuerySysInfo

From EDM2
(Redirected from OS2 API:CPI:DosQuerySysInfo)
Jump to: navigation, search

Description

Returns values of static system variables.

Syntax

rc = DosQuerySysInfo( ulStartIndex, ulLastIndex, pDataBuffer, ulDataBufferLength );

Parameters

ULONG ulStartIndex (input)
Index of the first info to query.
ULONG ulLastIndex (input)
Index of the last info to query. Equal to ulStartIndex if it is the only wanted info.
PVOID pDataBuffer (output)
Address to a data buffer to put the information in.
LONG ulDataBufferLength (input)
Size of pDataBuffer. Valid values for ulStartIndex and ulLastIndex
No. Name Description OS/2 Version
1 QSV_MAX_PATH_LENGTH Maximum length of a path name (bytes). Use this when allocating filename buffers. All
2 QSV_MAX_TEXT_SESSIONS Maximum number of text sessions. All
3 QSV_MAX_PM_SESSIONS Maximum number of PM sessions. All
4 QSV_MAX_VDM_SESSIONS Maximum number of DOS sessions. All
5 QSV_BOOT_DRIVE Boot drive (1 = A:, 2 = B:, 3 = C, and so on). All
6 QSV_DYN_PRI_VARIATION Absolute(= 0)/Dynamic(= 1) priority. All
7 QSV_MAX_WAIT Maximum wait time (seconds). All
8 QSV_MIN_SLICE Minimum time slice allowed (milliseconds). All
9 QSV_MAX_SLICE Maximum time slice allowed (milliseconds). All
10 QSV_PAGE_SIZE Memory page size (bytes). Default 4096 bytes. All
11 QSV_VERSION_MAJOR Major version number. All
12 QSV_VERSION_MINOR Minor version number. All
13 QSV_VERSION_REVISION Revision letter. All
14 QSV_MS_COUNT Value of a 32-bit, free-running counter (milliseconds). Zero at boot time. All
15 QSV_TIME_LOW Low-order 32 bits of the time since January 1, 1980 (seconds). All
16 QSV_TIME_HIGH High-order 32 bits of the time since January 1, 1980 (seconds). All
17 QSV_TOTPHYSMEM Total number of bytes of physical memory. All
18 QSV_TOTRESMEM Total number of bytes of system-resident memory. All
19 QSV_TOTAVAILMEM Maximum number of bytes available for all processes in the system RIGHT NOW. All
20 QSV_MAXPRMEM Maximum number of bytes available for this process RIGHT NOW. All
21 QSV_MAXSHMEM Maximum number of shareable bytes available RIGHT NOW. All
22 QSV_TIMER_INTERVAL Timer interval (1/10 milliseconds). All
23 QSV_MAX_COMP_LENGTH Maximum length of one component in a path name (bytes). All
24 QSV_FOREGROUND_FS_SESSION Session ID of the current foreground full screen session. (any PM, VIO or Win-DOS session would be ID = 1). Warp
25 QSV_FOREGROUND_PROCESS Process ID of the current foreground process. Warp
26 QSV_NUMPROCESSORS Number of processors in the computer. Warp

Returns

APIRET rc
Indicates if any error occured.
0 NO_ERROR
87 ERROR_INVALID_PARAMETER
111 ERROR_BUFFER_OVERFLOW

Include Info

#define INCL_DOSMISC
#include <os2.h>

Usage Explanation

DosQuerySysInfo queries different information about the system. and returns it in a buffer sent to it with the call.

Sample Code

ULONG aulBuffer[4];
APIRET rc;

rc = DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,
		     (void *)aulBuffer, 4*sizeof(ULONG));
if(rc) {
  printf("Error! DosQuerySysInfo returned %d.\n",rc);
  return(-1);
}
else {
  printf("You are running version %d.%d revision %c.\n",
          aulBuffer[0], aulBuffer[1], (char) aulBuffer[2]);
  printf("Your system has been running %d hour(s) and %d minute(s).\n",
          aulBuffer[3]/3600000, (aulBuffer[3]%3600000)/60000);
}

This example queries and displays the maximum length for a path name and the total amount of physical memory in bytes.

#define INCL_DOSMISC       /* DOS Miscellaneous values */
#define INCL_DOSERRORS     /* DOS Error values         */
#include <os2.h>
#include <stdio.h>

int main(VOID)  {

  ULONG   aulSysInfo[QSV_MAX] = {0};       /* System Information Data Buffer */
  APIRET  rc                  = NO_ERROR;  /* Return code                    */

  rc = DosQuerySysInfo(1L,                 /* Request all available system   */
                       QSV_MAX,            /* information                    */
                       (PVOID)aulSysInfo,
                       sizeof(ULONG)*QSV_MAX);

  if (rc != NO_ERROR) {
     printf("DosQuerySysInfo error: return code = %u\n", rc);
     return 1;
  } else {
     printf("Maximum length for a path name is %u characters.\n",
             aulSysInfo[QSV_MAX_PATH_LENGTH-1]);  /* Max length of path name */

     printf("Total physical memory is %u bytes.\n",
             aulSysInfo[QSV_TOTPHYSMEM-1]);       /* Total physical memory   */
  } /* endif */

   return NO_ERROR;
}

Related Functions