DosPhysicalDisk: Difference between revisions
Appearance
Created page with "==Description== Obtains information about partitionable disks. ==Syntax== <PRE> #define INCL_DOSPROCESS #include <os2.h> ULONG function; /* The type of information to..." |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Obtains information about partitionable disks. | Obtains information about partitionable disks. | ||
==Syntax== | ==Syntax== | ||
DosPhysicalDisk(function, pBuf, cbBuf, pParams, cbParams) | |||
==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. | ||
:The valid range is 0 to 255. | |||
; function (ULONG) - input : Device-specific function code. | ;pParams (PVOID) - input : Address of the command-specific argument list. | ||
The valid range is 0 to 255. | ;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. | |||
; pParams (PVOID) - input : Address of the command-specific argument list. | ;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. | |||
; cbParmLenMax (ULONG) - input : Length, in bytes, of pParams. | :OutputPointer to the length, in bytes, of the parameters returned. | ||
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. | :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. | |||
; pcbParmLen (PULONG) - in/out : Pointer to the length of parameters. | ;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. | |||
InputPointer to the length, in bytes, of the parameters passed in pParams. by the application. | ;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. | |||
OutputPointer to the length, in bytes, of the parameters returned. | :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. | |||
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== | ==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 | * 1 ERROR_INVALID_FUNCTION | ||
* 1 ERROR_INVALID_FUNCTION | * 6 ERROR_INVALID_HANDLE | ||
* 6 ERROR_INVALID_HANDLE | * 15 ERROR_INVALID_DRIVE | ||
* 15 ERROR_INVALID_DRIVE | * 31 ERROR_GEN_FAILURE | ||
* 31 ERROR_GEN_FAILURE | * 87 ERROR_INVALID_PARAMETER | ||
* 87 ERROR_INVALID_PARAMETER | * 111 ERROR_BUFFER_OVERFLOW | ||
* 111 ERROR_BUFFER_OVERFLOW | * 115 ERROR_PROTECTION_VIOLATION | ||
* 115 ERROR_PROTECTION_VIOLATION | * 117 ERROR_INVALID_CATEGORY | ||
* 117 ERROR_INVALID_CATEGORY | * 119 ERROR_BAD_DRIVER_LEVEL | ||
* 119 ERROR_BAD_DRIVER_LEVEL | * 163 ERROR_UNCERTAIN_MEDIA | ||
* 163 ERROR_UNCERTAIN_MEDIA | * 165 ERROR_MONITORS_NOT_SUPPORTED | ||
* 165 ERROR_MONITORS_NOT_SUPPORTED | |||
==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== | ||
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. | 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. | ||
< | <code> | ||
#define INCL_DOSDEVICES /* Device values */ | #define INCL_DOSDEVICES /* Device values */ | ||
#define INCL_DOSERRORS /* DOS error values */ | #define INCL_DOSERRORS /* DOS error values */ | ||
#include <os2.h> | #include <os2.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
int main (VOID) { | 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, | rc = DosPhysicalDisk(INFO_COUNT_PARTITIONABLE_DISKS, | ||
&usNumDrives, | &usNumDrives, | ||
Line 104: | Line 65: | ||
NULL, /* No parameter for this function */ | NULL, /* No parameter for this function */ | ||
0L); | 0L); | ||
if (rc != NO_ERROR) { | if (rc != NO_ERROR) { | ||
printf("DosPhysicalDisk error: return code = %u\n", rc); | printf("DosPhysicalDisk error: return code = %u\n", rc); | ||
Line 111: | Line 72: | ||
printf("DosPhysicalDisk: %u partitionable disk(s)\n",usNumDrives); | printf("DosPhysicalDisk: %u partitionable disk(s)\n",usNumDrives); | ||
} | } | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</code> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosBeep]] | ||
* [[ | * [[DosDevConfig]] | ||
* [[ | * [[DosDevIOCtl]] | ||
[[Category: | [[Category:Dos]] |
Latest revision as of 12:33, 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;
}