DosPhysicalDisk

From EDM2
Jump to: navigation, search

Obtains information about partitionable disks.

Syntax

DosPhysicalDisk(function, pBuf, cbBuf, pParams, cbParams)

Parameters

hDevice (HFILE) - input 
Device handle returned by DosOpen, or a standard (open) device handle.
category (ULONG) - input 
Device category.
The valid range is 0 to 255.
function (ULONG) - input 
Device-specific function code.
The valid range is 0 to 255.
pParams (PVOID) - input 
Address of the command-specific argument list.
cbParmLenMax (ULONG) - input 
Length, in bytes, of pParams.
This is the maximum length of the data to be returned in pParams. pcbParmLen may be larger than this on input, but not on output.
pcbParmLen (PULONG) - in/out 
Pointer to the length of parameters.
InputPointer to the length, in bytes, of the parameters passed in pParams. by the application.
OutputPointer to the length, in bytes, of the parameters returned.
If this function returns ERROR_BUFFER_OVERFLOW, then pcbParmLen points to the size of the buffer required to hold the parameters returned. No other data is returned in this case.
pData (PVOID) - input 
Address of the data area.
cbDataLenMax (ULONG) - input 
Length, in bytes, of pData.
This is the maximum length of the data to be returned in pData. pcbDataLen may be larger than this on input, but not on output.
pcbDataLen (PULONG) - in/out 
Pointer to the length of data.
Input Pointer to the length, in bytes, of the data passed by the application in pData.
Output Pointer to the length, in bytes, of the data returned.
If this function returns ERROR_BUFFER_OVERFLOW, then pcbDataLen points to the size of the buffer required to hold the data returned.

Return Code

ulrc (APIRET) - returns

DosDevIOCtl returns one of the following values:

  • 0 NO_ERROR
  • 1 ERROR_INVALID_FUNCTION
  • 6 ERROR_INVALID_HANDLE
  • 15 ERROR_INVALID_DRIVE
  • 31 ERROR_GEN_FAILURE
  • 87 ERROR_INVALID_PARAMETER
  • 111 ERROR_BUFFER_OVERFLOW
  • 115 ERROR_PROTECTION_VIOLATION
  • 117 ERROR_INVALID_CATEGORY
  • 119 ERROR_BAD_DRIVER_LEVEL
  • 163 ERROR_UNCERTAIN_MEDIA
  • 165 ERROR_MONITORS_NOT_SUPPORTED

Remarks

DosPhysicalDisk obtains information about partitionable disks. The handle returned for the specified partitionable disk can only be used with the DosDevIOCtl function for the Category 09h Physical Disk Control IOCtl Commands. Use of the handle for a physical partitionable disk is not permitted for handle-based file system functions, such as DosRead or DosClose.

Example Code

This example obtains the total number of partitionable disks in the system. A partitionable disk is a physical disk drive that can be formatted into partitions.

#define INCL_DOSDEVICES   /* Device values    */
#define INCL_DOSERRORS    /* DOS error values */
#include <os2.h>
#include <stdio.h>

int main (VOID) {

   USHORT  usNumDrives  = 0;               /* Data return buffer        */
   ULONG   ulDataLen    = sizeof(USHORT);  /* Data return buffer length */
   APIRET  rc           = NO_ERROR;        /* Return code               */

  /* Request a count of the number of partitionable disks in the system */

   rc = DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS,
                        &usNumDrives,
                        ulDataLen,
                        NULL,         /* No parameter for this function */
                        0L);

   if (rc != NO_ERROR) {
      printf("DosPhysicalDisk error: return code = %u\n", rc);
      return 1;
   } else {
      printf("DosPhysicalDisk:  %u partitionable disk(s)\n",usNumDrives);
   }

  return NO_ERROR;
}

Related Functions