Jump to content

DosPhysicalDisk: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
==Description==
Obtains information about partitionable disks.  
Obtains information about partitionable disks.  


==Syntax==
==Syntax==
<PRE>
  DosPhysicalDisk(function, pBuf, cbBuf, pParams, cbParams)
#define INCL_DOSPROCESS
#include <os2.h>
 
ULONG    function;  /*  The type of information to obtain about the partitionable disks. */
PVOID    pBuf;      /*  The address of the buffer where the returned information is placed. */
ULONG    cbBuf;    /*  The length, in bytes, of the data buffer. */
PVOID    pParams;  /*  The address of the buffer used for input parameters. */
ULONG    cbParams;  /*  The length, in bytes, of the parameter buffer. */
APIRET    ulrc;      /* Return Code. */
 
ulrc = DosPhysicalDisk(function, pBuf, cbBuf,
        pParams, cbParams);
</PRE>


==Parameters==
==Parameters==
; hDevice (HFILE) - input : Device handle returned by DosOpen, or a standard (open) device handle.
;hDevice (HFILE) - input : Device handle returned by DosOpen, or a standard (open) device handle.
; category (ULONG) - input : Device category.
;category (ULONG) - input : Device category.
:The valid range is 0 to 255.  
:The valid range is 0 to 255.  
; function (ULONG) - input : Device-specific function code.
;function (ULONG) - input : Device-specific function code.
:The valid range is 0 to 255.
:The valid range is 0 to 255.
; pParams (PVOID) - input : Address of the command-specific argument list.
;pParams (PVOID) - input : Address of the command-specific argument list.
;cbParmLenMax (ULONG) - input : Length, in bytes, of pParams.
;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.
: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.
;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.
: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.  
: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.
: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.
;pData (PVOID) - input : Address of the data area.
; cbDataLenMax (ULONG) - input : Length, in bytes, of pData.
;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.
: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.
;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.
: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.
:Output Pointer to the length, in bytes, of the data returned.
Line 41: Line 27:
==Return Code==
==Return Code==
  ulrc (APIRET) - returns
  ulrc (APIRET) - returns
DosDevIOCtl returns one of the following values:  
DosDevIOCtl returns one of the following values:  
* 0 NO_ERROR
* 0 NO_ERROR
Line 57: Line 42:


==Remarks==
==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.
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==
==Example Code==

Revision as of 12:31, 17 September 2017

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