home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cenvi23.zip / DEVIOCTL.LIB < prev    next >
Text File  |  1994-03-08  |  4KB  |  75 lines

  1. // DevIOCtl.lib - Interface to the DosDevIOCtl call
  2. // ver.1
  3.  
  4. DosDevIOCtl(DevHandle,Category,Function,
  5.             ParameterBLOb,MaxRetParameterSize,ParameterSize,
  6.             DataBLOb,MaxRetDataSize,DataSize)
  7.    // DevHandle: Device handle, such as returned by DosOpen()
  8.    // Category: Device Categoring for this IOCtl call
  9.    // Function: Function code within that Category
  10.    // ParameterBLOb: Command-specific argument for this Category and Function,
  11.    //           or NULL if this function takes no arguments
  12.    // MaxRetParameterSize: For function calls that return arguments in ParameterBLOb,
  13.    //           this is the maximum size those arguments can be.  If this is
  14.    //           not 0 then ParameterBLOb will be made big enough.  If zero then
  15.    //           this assumes that function returns no parameters in ParameterBLOb.
  16.    // ParameterSize: On input, this is the size of Parameters in ParameterBLOb, on
  17.    //           output this is the size of bytes that Function returned in ParameterBlob.
  18.    //           If MaxRetParameterSize is 0 then this value is not altered.
  19.    //           If this function returns ERROR_BUFFER_OVERFLOW then this contains
  20.    //           the size of the buffer required to hold parameters
  21.    // DataBLOb: Command-specific data for this Category and Function,
  22.    //           or NULL if this function uses no data area
  23.    // MaxRetDataSize: For function calls that return data in this data area,
  24.    //           this is the maximum size that data can be.  If this is
  25.    //           not 0 then DataBLOb will be made big enough.  If zero then
  26.    //           this assumes that function returns no data in DataBLOb.
  27.    // DataSize: On input, this is the size of data area DataBLOb, on
  28.    //           output this is the size of bytes that Function returned in DataBlob.
  29.    //           If MaxRetDataSize is 0 then this value is not altered.
  30.    //           If this function returns ERROR_BUFFER_OVERFLOW then this contains
  31.    //           the size of the buffer required to the data.
  32.    // Return: Returns 0 if no error; else error code, one of which may include:
  33.       #define ERROR_INVALID_FUNCTION         1
  34.       #define ERROR_INVALID_HANDLE           6
  35.       #define ERROR_INVALID_DRIVE            15
  36.       #define ERROR_GEN_FAILURE              31
  37.       #define ERROR_INVALID_PARAMETER        87
  38.       #define ERROR_BUFFER_OVERFLOW          111
  39.       #define ERROR_PROTECTION_VIOLATION     115
  40.       #define ERROR_INVALID_CATEGORY         117
  41.       #define ERROR_BAD_DRIVER_LEVEL         119
  42.       #define ERROR_UNCERTAIN_MEDIA          163
  43.       #define ERROR_MONITORS_NOT_SUPPORTED   165
  44. {
  45.    // Make blobs to hold pointers to parameter size
  46.    BLObPut(_ParameterSize,defined(ParameterSize) ? ParameterSize : 0,UWORD32);
  47.    BLObPut(_DataSize,defined(DataSize) ? DataSize : 0,UWORD32);
  48.  
  49.    // Make sure Parameter and Data blobs are bi enough for return data
  50.    if ( MaxRetParameterSize
  51.      && ( !defined(ParameterBLOb) || NULL == ParameterBLOb || (BLObSize(ParameterBLOb) < MaxRetParameterSize) ) )
  52.       BLObSize(ParameterBLOb,MaxRetParameterSize);
  53.    if ( MaxRetDataSize
  54.      && ( !defined(DataBLOb) || NULL == DataBLOb || (BLObSize(DataBLOb) < MaxRetDataSize) ) )
  55.       BLObSize(DataBLOb,MaxRetDataSize);
  56.  
  57.    // Make call to DosDevIOCtl
  58.    #define ORD_DOS32DEVIOCTL     284
  59.    rc = DynamicLink("doscalls",ORD_DOS32DEVIOCTL,BIT32,CDECL,
  60.                     DevHandle,Category,Function,
  61.                     defined(ParameterBLOb) ? ParameterBLOb : NULL,
  62.                     MaxRetParameterSize,_ParameterSize,
  63.                     defined(DataBLOb) ? DataBLOb : NULL,
  64.                     MaxRetDataSize,_DataSize);
  65.  
  66.    // Return new parameter and data size if they were defined
  67.    if ( MaxRetParameterSize )
  68.       ParameterSize = BLObGet(_ParameterSize,0,UWORD32);
  69.    if ( MaxRetDataSize )
  70.       DataSize = BLObGet(_DataSize,0,UWORD32);
  71.  
  72.    return(rc);
  73. }
  74.  
  75.